HMG 3.4.0

HMG Unicode versions 3.1.x related

Moderator: Rathinagiri

Post Reply
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: HMG 3.4.0

Post by serge_girard »

Thanks Guys, seems I missed this important update.

Serge
There's nothing you can do that can't be done...
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG 3.4.0

Post by mol »

I need to present data from relation 1 to n when one invoice contains few positions.
I've used two grids to present two .dbf files.
I have a strange problem with grid. When I change record in grid by mouse, OnChange event is fired after record pointer change, but, when I move by arrow keys, OnChange is fired before record pointer change.
Please compile my sample ant observe it.
Attachments
sample1.zip
(1.34 KiB) Downloaded 200 times
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: HMG 3.4.0

Post by andyglezl »

Hola Mol

Asi de primer intento lo probe pero da error
-----------------------------------------------------
Hello Mol

So I tried it first attempts but fails
Attachments
sample1.png
sample1.png (193.33 KiB) Viewed 4106 times
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: HMG 3.4.0

Post by andyglezl »

Mol, solo quieres consultar los datos o tambien editarlos ?
--------------------------------------------------------------------
Mol, just want to query the data in the Grid or also edit them?
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: HMG 3.4.0

Post by andyglezl »

Aqui la forma como yo lo hago, espero les sirva.
--------------------------------------------------------
Here's how I do it, I hope they serve.

Code: Select all

/*
* HMG Virtual Grid Demo
* (c) 2009 Roberto Lopez
*/

#include "hmg.ch"

Function Main
	Local aValue := { 0 , 0 }
	local aStructureOfHeaders, aStructureOfPositions
	
	SET EXCLUSIVE ON
	//REQUEST("DBFCDX")
	
	// first, we need to create database for test
	// we will have 1 to n relation from headers to positions
	if file("invoices.dbf")
		delete file headers.dbf
	endif
	if file("positions.dbf")
		delete file positions.dbf
	endif
	
	aStructureOfInvoices := {	{ "ID","C",6,0},;
								{ "FullNumber","C",11,0} }

	aStructureOfPositions	:= {	{ "ID","C",6,0},;
									{ "Lp","N",2,0 } ,;
									{ "TimeStamp","C",20,0},;
									{ "AnyText","C",40,0 } }

	DBCreate("invoices",aStructureOfInvoices)
	DBCreate("positions",aStructureOfPositions)

	use invoices new
	index on ID to invoices1
	set index to invoices1
	
	use positions new
	index on ID to positions1
	set index to positions1
	
	for i = 20 to 1 STEP -1
		invoices->(AddRec())
		replace;
			invoices->ID	with str(i,6,0) ,;
			invoices->FullNumber with str(i,6,0)+"/"+str(year(date()),4,0)
		
		for j := 1 to 2+i*2
			positions->(AddRec())
			replace;
				positions->ID	with invoices->ID ,;
				positions->LP	with j ,;
				positions->TimeStamp	with time() ,;
				positions->AnyText	with "This is pos.no "+alltrim(str(j,0))+" of header record #"+alltrim(str(i,0))
		next j
	next i
	**************************************		I have never used "OrdScope"
	*invoices->(DBGoTop())
	*positions->(OrdScope(0,invoices->ID))
	*positions->(OrdScope(1,invoices->ID))
	*positions->(DBGoTop())	
	**************************************		
	
	* Headers Grid Column Controls Definitions
	*aInvoicesControls := {	{'TEXTBOX','CHARACTER'} ,;
	*						{'TEXTBOX','CHARACTER'} }

	*aPositionsControls := { {'TEXTBOX','CHARACTER'} ,;
	*						{'TEXTBOX','NUMERIC'} ,;
	*						{'TEXTBOX','CHARACTER'} ,;
	*						{'TEXTBOX','CHARACTER'} }
	aInvoicesHeaders	:= { "ID","Number"}
	aInvoicesWidths	:= { 60,120}
	*aInvoicesJust	:= { 0,1}
	*aInvoicesFields	:= {"ID","FullNumber"}
	
	aPositionsHeaders	:=	{ "ID","Lp","TimeStamp","Any text" }
	aPositionsWidths	:=	{ 60,60,100,300 }
	*aPositionsJust		:=	{ 0,1,0,0 }
	*aPositionsFields	:=	{ "ID","LP","TimeStamp","AnyText" }
	
	DEFINE WINDOW Form_1 AT 0,0 WIDTH 900 HEIGHT 610 TITLE 'GRID and DBEval() test By AndyGlezL' MAIN 

		@ 10,10 LABEL L1 VALUE "Invoices"
		@ 40,10 GRID Grid_Invoices WIDTH 210 HEIGHT 500 HEADERS aInvoicesHeaders WIDTHS aInvoicesWidths ON CHANGE UpdatePositions( This.Value )
			// ROWSOURCE "invoices" ;
			// COLUMNFIELDS aInvoicesFields ;
			// COLUMNCONTROLS aInvoicesControls ;
			// ON CHANGE UpdatePositions( )
			
			// Fill Grid_Invoices
			Invoices->( DBEval( { || Form_1.Grid_Invoices.AddItem( { ID, FullNumber } ) } ) )

		@ 10,240 LABEL L2 VALUE "Positions"
		@ 40,240 GRID Grid_Positions WIDTH 640 HEIGHT 500 HEADERS aPositionsHeaders WIDTHS aPositionsWidths
			// ROWSOURCE "positions" ;
			// COLUMNFIELDS aPositionsFields ;
			// COLUMNCONTROLS aPositionsControls
		
	END WINDOW
	CENTER WINDOW Form_1
	ACTIVATE WINDOW Form_1
Return
*******************************************************************************
Procedure AddRec
	append blank
 return 
*******************************************************************************
/*
Procedure UpdatePositions()

	// clear previous ordscopes
	positions->(OrdScope(0,NIL))
	positions->(OrdScope(1,NIL))
	positions->(DBGoTop())
	
	MsgInfo("Positions will be set to ID #"+invoices->ID)
	
	positions->(OrdScope(0,invoices->ID))
	positions->(OrdScope(1,invoices->ID))
	positions->(DBGoTop())
	Form_1.Grid_Positions.Refresh
	
return	
*/
Procedure UpdatePositions( nRow )			// New ON CHANGE Procedure UpdatePositions
	Form_1.Grid_Positions.DeleteAllItems
	cKey := GetProperty( "Form_1", "Grid_Invoices", "CellEx", nRow, 1 )		// Get value from Column 1 of "Grid_Invoices"
    positions->( DBSeek( cKey, .T. ) )
	positions->( DBEval( { || IF( cKey = ID, Form_1.Grid_Positions.AddItem( { ID, STR( LP ), TimeStamp, AnyText } ), nil ) } ) )
Return
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG 3.4.0

Post by mol »

Hi Andres!
Thanks for your interesting!
I'm sure we can find few working solutions, but problem, which I want to point doesn't lay in method of viewing positions table.
It lays in firing ONCHANGE code...



Edit:


I've modified a little my sample to allow compile with BROWSE. It's strange, browse works better. Try to compile
Regards, Marek
Attachments
sample1.zip
(1.45 KiB) Downloaded 250 times
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: HMG 3.4.0

Post by Javier Tovar »

Hi Marek,

For some reason I can not decompress your last file?
He tells me that the file has a format or corrupt.

regards
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: HMG 3.4.0

Post by Javier Tovar »

OK stay and forget my anterioir mail.

regards
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: HMG 3.4.0

Post by andyglezl »

...but problem, which I want to point doesn't lay in method of viewing positions table.
It lays in firing ONCHANGE code...
como que no me quedo claro, estoy utilizando el GRID y el evento ONCHANGE de tu ejemplo con mouse y teclas
y con el nuevo procedimiento "UpdatePositions( nRow )" y creo que funciona bien...

Tal vez el problema este en el "ORDSCOPE" ó en "ROWSOURCE"
----------------------------------------------------------------------------------------------------------------------------------------
as they do not stay clear, I am using the GRID and ONCHANGE event your example with mouse and keys
and the new procedure "UpdatePositions (nRow)" and I think it works well ...

Maybe the problem is in the "ORDSCOPE" or the "RowSource"
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
vientopamperosur
Posts: 59
Joined: Thu Aug 28, 2014 10:13 am
DBs Used: DBF, SQLite, MySQL, MariaDB, PostgreSQL
Location: Buenos Aires
Contact:

Re: HMG 3.4.0

Post by vientopamperosur »

Gracias por tu aporte, he probado algunas cosas y funcionan a la perfección.
Post Reply