Probando el Grid

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
claudiotedesco
Posts: 132
Joined: Thu Jul 31, 2008 12:05 pm

Probando el Grid

Post by claudiotedesco »

Hola

Mi consulta es la siguiente tengo un grid con una base donde estoy haciendo unas pruebas y veo que no puedo guardar un registro nuevo.
Adjunto el codigo para ver cual seria el error
Gracias

Claudio

* HMG-IDE Form Designer Generated Code
* (c) Roberto Lopez - http://harbourminigui.googlepages.com

DEFINE WINDOW TEMPLATE AT 261 , 371 WIDTH 550 HEIGHT 350 VIRTUAL WIDTH Nil VIRTUAL HEIGHT Nil TITLE "ventana 4" ICON NIL MODAL CURSOR NIL ON INIT Nil ON RELEASE Nil ON INTERACTIVECLOSE Nil ON MOUSECLICK Nil ON MOUSEDRAG Nil ON MOUSEMOVE Nil ON SIZE Nil ON PAINT Nil BACKCOLOR Nil ON GOTFOCUS Nil ON LOSTFOCUS Nil ON SCROLLUP Nil ON SCROLLDOWN Nil ON SCROLLLEFT Nil ON SCROLLRIGHT Nil ON HSCROLLBOX Nil ON VSCROLLBOX Nil

DEFINE MAIN MENU
DEFINE POPUP "Archivo"
MENUITEM "Borrar" ACTION ventana4.Grid_1.Delete
MENUITEM "Ingreso" ACTION ventana4.Grid_1.Append
END POPUP
END MENU

DEFINE LABEL Label_1
ROW 10
COL 200
WIDTH 130
HEIGHT 20
VALUE "BASE de DATOS"
FONTNAME "Arial"
FONTSIZE 12
TOOLTIP ""
FONTBOLD .T.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
VISIBLE .T.
TRANSPARENT .F.
ACTION Nil
AUTOSIZE .F.
BACKCOLOR {0,255,255}
FONTCOLOR {255,128,192}
END LABEL

DEFINE GRID Grid_1
ROW 70
COL 40
WIDTH 460
HEIGHT 160
ITEMS { {"","",""} }
VALUE { 1,1 }
WIDTHS { 100,150,150}
HEADERS {'Codigo', "Nombre","Apellido"}
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
ONCHANGE Nil
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
ONDBLCLICK Nil
ONHEADCLICK Nil
ONQUERYDATA Nil
MULTISELECT .F.
ALLOWEDIT .T.
VIRTUAL .F.
DYNAMICBACKCOLOR Nil
DYNAMICFORECOLOR Nil
COLUMNWHEN Nil
COLUMNVALID Nil
COLUMNCONTROLS {{"TEXTBOX", "NUMERIC","99999" },{"TEXTBOX", "CHARACTER"},{"TEXTBOX", "CHARACTER"}}
SHOWHEADERS .T.
CELLNAVIGATION .F.
NOLINES .F.
HELPID Nil
IMAGE Nil
JUSTIFY Nil
ITEMCOUNT Nil
BACKCOLOR NIL
FONTCOLOR NIL
HEADERIMAGES Nil
ROWSOURCE 'agenda'
COLUMNFIELDS {'codigo','nombre','apellido'}
ALLOWAPPEND .T.
ALLOWDELETE .T.
BUFFERED .T.
DYNAMICDISPLAY Nil
ONSAVE Nil
END GRID

DEFINE BUTTON Button_1
ROW 270
COL 190
WIDTH 100
HEIGHT 28
ACTION ventana4_button_1_action()
CAPTION "Grabar cambios"
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
HELPID Nil
FLAT .F.
TABSTOP .T.
VISIBLE .T.
TRANSPARENT .F.
MULTILINE .F.
PICTURE Nil
PICTALIGNMENT TOP
END BUTTON

DEFINE BUTTON Button_2
ROW 270
COL 410
WIDTH 100
HEIGHT 28
ACTION ventana4_button_2_action()
CAPTION "Salir sin Grabar"
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
HELPID Nil
FLAT .F.
TABSTOP .T.
VISIBLE .T.
TRANSPARENT .F.
MULTILINE .F.
PICTURE Nil
PICTALIGNMENT TOP
END BUTTON

END WINDOW


#include "hmg.ch"

declare window ventana4

Function ventana4_button_1_action

ventana4.Grid_1.SAVE
ventana4.Grid_1.refresh

Return Nil

#include "hmg.ch"

declare window ventana4

Function ventana4_button_2_action

close all
ventana4.release

Return Nil
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Probando el Grid

Post by Roberto Lopez »

claudiotedesco wrote:Hola

Mi consulta es la siguiente tengo un grid con una base donde estoy haciendo unas pruebas y veo que no puedo guardar un registro nuevo.
Adjunto el codigo para ver cual seria el error
Gracias

Claudio
<...>
Please, attach the complete sample with all needed files to make it work, so I'll be able to test it.

TIA.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
claudiotedesco
Posts: 132
Joined: Thu Jul 31, 2008 12:05 pm

Re: Probando el Grid

Post by claudiotedesco »

Hola adjunto el proyecto con los ejemplos
Saludos
Attachments
ej1.rar
(653.46 KiB) Downloaded 331 times
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Probando el Grid

Post by Roberto Lopez »

claudiotedesco wrote:Hola adjunto el proyecto con los ejemplos
Saludos
Gracias/Thanks!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Probando el Grid

Post by Roberto Lopez »

claudiotedesco wrote:Hola adjunto el proyecto con los ejemplos
Saludos
Your sample has many windows and procedures. Could be you so kind to indicate what exactly the problem is?

Tu ejemplo tiene varias ventanas y procedimientos. ¿podrías indicarme cual es exactamente el problema?

Gracias/Thanks.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Probando el Grid

Post by Roberto Lopez »

Roberto Lopez wrote:
claudiotedesco wrote:Hola adjunto el proyecto con los ejemplos
Saludos
Your sample has many windows and procedures. Could be you so kind to indicate what exactly the problem is?

Tu ejemplo tiene varias ventanas y procedimientos. ¿podrías indicarme cual es exactamente el problema?

Gracias/Thanks.
I've found the problem.

Thanks for the report.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Probando el Grid

Post by Roberto Lopez »

Claudio,

I've verified the problem adding records that you point in your sample.

But, to make the analysis easier, I've reduced your sample to the specific problem and... it worked fine.

You can test with the .dbf you've supplied with your sample:

Code: Select all

#include <hmg.ch>

Function Main

	DEFINE WINDOW Win1 AT 207 , 294 WIDTH 424 HEIGHT 202 TITLE "" MAIN 

		DEFINE BUTTON Button_1
			ROW    60
			COL    130
			ACTION main_button_1_action()
			CAPTION "Base de datos"
		END BUTTON

	END WINDOW

        Win1.Center
      
        Win1.Activate
      
Return

procedure main_button_1_action()

*	USE AGENDA 
*	ZAP
*	USE

	USE AGENDA 

	DEFINE WINDOW Win2 AT 118 , 77 WIDTH 550 HEIGHT 350 TITLE "" MODAL 

		DEFINE MAIN MENU
			DEFINE POPUP "Menu"
				MENUITEM "Borrar" ACTION Win2.Grid_1.Delete
				MENUITEM "Ingreso" ACTION Win2.Grid_1.Append
			END POPUP
		END MENU

		DEFINE GRID Grid_1
			ROW    70
			COL    40
			WIDTH  460
			HEIGHT 160
			VALUE { 1,1 }
			WIDTHS { 100,150,150}
			HEADERS {'Codigo', "Nombre","Apellido"}
			COLUMNCONTROLS {{"TEXTBOX", "NUMERIC","99999" },{"TEXTBOX", "CHARACTER"},{"TEXTBOX", "CHARACTER"}}
			ROWSOURCE 'agenda'
			COLUMNFIELDS {'codigo','nombre','apellido'}
			ALLOWAPPEND .T.
			ALLOWDELETE .T.
			ALLOWEDIT .T.
		END GRID

		DEFINE BUTTON Button_1
			ROW    260
			COL    190
			WIDTH  100
			HEIGHT 28
			ACTION Win2.Grid_1.Save 
			CAPTION "Grabar cambios"
		END BUTTON

	END WINDOW

	Win2.Center

	Win2.Activate

return
There is two possibilities:

1. Default values provided by IDE for Grid properties are confusing it and creating the problem.

2. There is something in your code creating the problem.

I guess that there is big chances that be the first. I'll still researching.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Probando el Grid

Post by Roberto Lopez »

I've verified the following:

If you replace the grid definition by the one specified by IDE in your sample, the problem that you signal comes back.

I'll work on it.

Thanks again for reporting.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Probando el Grid

Post by Roberto Lopez »

Roberto Lopez wrote:I've verified the following:

If you replace the grid definition by the one specified by IDE in your sample, the problem that you signal comes back.

I'll work on it.

Thanks again for reporting.
I've fixed.

You must replace the attached files on 3.0.27 release.

It will work fine with your original sample.

A little tip: 'Save' method will automatically do a refresh, so there is no need to call 'refresh' method after saving.

So, your code:

Code: Select all

#include "hmg.ch"

declare window ventana4

Function ventana4_button_1_action
    
    ventana4.Grid_1.SAVE
    ventana4.Grid_1.refresh
    
Return Nil
Should be:

Code: Select all

#include "hmg.ch"

declare window ventana4

Function ventana4_button_1_action
    
    ventana4.Grid_1.SAVE
   
Return Nil
Attachments
patch327a.rar
(200.46 KiB) Downloaded 259 times
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
Post Reply