I need to create something like tree combined with grid

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

I need to create something like tree combined with grid

Post by mol »

Hi guys!
I need to create a control, which will be expandable like tree, but with few columns in row - like a grid.
Image


Does anybody have an idea how to do it?
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: I need to create something like tree combined with grid

Post by andyglezl »

Ya trataste con esto ?
*--------------------------------------------
Have you tried this yet?


GRID Control improvement

Note: Grid Group is not available when application is running on Windows versions of 32-bits
You can check if your application is running on Win32 with the function HMG_IsRunAppInWin32()

- New Features:
- <ParentWindowName>.<GridControlName>.GroupEnabled [ := | -->] lBoolean
- <ParentWindowName>.<GridControlName>.GroupDeleteAll
- <ParentWindowName>.<GridControlName>.GroupDelete ( nGroupID )
- <ParentWindowName>.<GridControlName>.GroupDeleteAllItems ( nGroupID )
- <ParentWindowName>.<GridControlName>.GroupExist ( nGroupID ) --> lBoolean
- <ParentWindowName>.<GridControlName>.GroupCheckBoxAllItems ( nGroupID ) := lBoolean
- <ParentWindowName>.<GridControlName>.GroupGetAllItemIndex ( nGroupID ) --> anItemIndex
- <ParentWindowName>.<GridControlName>.GroupExpand ( nGroupID )
- <ParentWindowName>.<GridControlName>.GroupCollapsed ( nGroupID )
- <ParentWindowName>.<GridControlName>.GroupAdd ( nGroupID [, nPosition ] )
- <ParentWindowName>.<GridControlName>.GroupInfo ( nGroupID ) [ := | -->] { [ cHeader ] , [ nAlignHeader ] , [ cFooter ] , [ nAlingFooter ] , [ nState ] }
- <ParentWindowName>.<GridControlName>.GroupItemID ( nItem ) [ := | -->] nGroupID

- nAlignHeader [ := | -->] GRID_GROUP_LEFT | GRID_GROUP_CENTER | GRID_GROUP_RIGHT
- nAlingFooter [ := | -->] GRID_GROUP_LEFT | GRID_GROUP_CENTER | GRID_GROUP_RIGHT
- nState [ := | -->] GRID_GROUP_NORMAL | GRID_GROUP_COLLAPSED
Andrés González López
Desde Guadalajara, Jalisco. México.
EduardoLuis
Posts: 682
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina

Re: I need to create something like tree combined with grid

Post by EduardoLuis »

Hi Mol:

What mention Andyglez it's correct. Unfortunately don't run under Win 32 (I think that all my app can run under Win32 or 64)
But, with some magician programating you may adapt TREE_SORT_DIR to do that.-
I've not test it, but, who can say NO in advance.- Just experiment.
Hopping these helps you.
With regards.
Eduardo
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: I need to create something like tree combined with grid

Post by mol »

I'm trying to get similat effect with virtualgrid.
My application must run on 32 bit :-(
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: I need to create something like tree combined with grid

Post by andyglezl »

Es solo una idea... :idea:
*-----------------------------------
It's just an idea... :idea:

Code: Select all

		DEFINE TREE Tree_1 AT 10,10 WIDTH 200 HEIGHT 400 VALUE 3;
		NODEIMAGES { "doc_fl.bmp" };
		ITEMIMAGES { "cl_fl.bmp", "op_fl.bmp" }

			DO WHILE Ctes->IMPORTE > 0 
				NODE Ctes->NAME  
					TREEITEM "Column1" + " | " + "Column2" +  " | " + "Column3" +  " | " + TRANSFORM( Ctes->IMPORTE, "9,999,999.99")
					TREEITEM "Column1" + " | " + "Column2" +  " | " + "Column3" +  " | " + TRANSFORM( Ctes->IMPORTE, "9,999,999.99")
					TREEITEM "Column1" + " | " + "Column2" +  " | " + "Column3" +  " | " + TRANSFORM( Ctes->IMPORTE, "9,999,999.99")
					TREEITEM REPLICATE("_",200)
					TREEITEM REPLICATE(" ",185) + TRANSFORM( Ctes->SUMA, "99,999,999.99")
				END NODE
			ENDDO
		END TREE
Andrés González López
Desde Guadalajara, Jalisco. México.
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: I need to create something like tree combined with grid

Post by edk »

Another an idea :idea: :

Code: Select all

#include "hmg.ch"

Function main()

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 ;
		HEIGHT 480 ;
		TITLE 'TreeView Sample' ;
		MAIN ;
		BACKCOLOR WHITE


		DEFINE TREE Tree_1 AT 10,30 WIDTH 120 HEIGHT 22 ON EXPAND tree_expand() ITEMIDS
		
			NODE 'Expand Grid' ID 1
			END NODE
			
		END TREE
		
		Form_1.Tree_1.Cargo ( 1 ) :=  { | nTreeValue | ShowGrid( nTreeValue ) }
		Form_1.Tree_1.HasButton ( 1 ) :=  .T.
		HMG_ChangeWindowStyle(Form_1.Tree_1.Handle, Nil, 512, .T.,.T.)
		

	END WINDOW

	ACTIVATE WINDOW Form_1

Return

function tree_expand()
Local xCargo:=Form_1.Tree_1.Cargo ( This.TreeItemValue )
IF xCargo = Nil
	RETURN
ENDIF
EVAL( xCargo, This.TreeItemValue )
RETURN



Function ShowGrid( nTreevalue )
Form_1.Tree_1.Item( nTreevalue ) := "Collapse Grid"

@ 30,50 GRID Grid_1 OF Form_1 ;
		WIDTH 400 ;
		HEIGHT 200 ;
		HEADERS {'Column 1','Column 2','Column 3'} ;
		WIDTHS {140,140,140};
		VIRTUAL ;
		ITEMCOUNT 100000000 ;
		ON QUERYDATA QueryTest() 

Form_1.Tree_1.Cargo ( nTreevalue ) :=  { | nTreeValue | HideGrid( nTreeValue ) }

Return

Procedure QueryTest()

	This.QueryData := Str ( This.QueryRowIndex ) + ',' + Str ( This.QueryColIndex )

Return

Function HideGrid( nTreevalue )
Form_1.Tree_1.Item( nTreevalue ) := "Expand Grid"
Form_1.Grid_1.Release
Form_1.Tree_1.Cargo ( nTreevalue ) :=  { | nTreeValue | ShowGrid( nTreeValue ) }
Return

User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: I need to create something like tree combined with grid

Post by mol »

Thanks guys!
But, any sample does it in this way as I need :(
I don't have to expandable row at now, so, I'm using virtual grid with dynamic fonts and dynamic colors. It looks really fine.

It would be great to have possibility to define cell borders individually
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: I need to create something like tree combined with grid

Post by Rathinagiri »

If your requirement is to just show data, you can use HTML Table and HTML Control.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: I need to create something like tree combined with grid

Post by mol »

It must be clickable ;-)
But now, virtual grid is enough solution.
I'm wondering if it's a way to show/hide selected rows?
Something like expand/collapse in tree.
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: I need to create something like tree combined with grid

Post by edk »

Może coś takiego na wirtualnej siatce?

Code: Select all

/*
* HMG HeaderImages Property Test
* (c) 2008 Roberto Lopez
*/

#include "hmg.ch"

Function Main

Local arows:=LoadItems(), lShowAll:=.F.

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 550 ;
		HEIGHT 400 ;
		TITLE 'Hello World!' ;
		MAIN

		DEFINE MAIN MENU
			DEFINE POPUP 'Records'
				MENUITEM 'Show all records' ACTION (lShowAll:=.T., Form_1.Grid_1.ITEMCOUNT:=QueryTest(aRows, lShowAll), Form_1.Grid_1.Refresh)
				MENUITEM 'Hide some records' ACTION (lShowAll:=.F., Form_1.Grid_1.ITEMCOUNT:=QueryTest(aRows, lShowAll), Form_1.Grid_1.Refresh)
			END POPUP
		END MENU

		
		@ 10,10 GRID Grid_1 ;
		WIDTH 500 ;
		HEIGHT 330 ;
		HEADERS {'Last Name','First Name','Phone'} ;
		WIDTHS {140,140,140};
		VIRTUAL ;
		ITEMCOUNT QueryTest(aRows, lShowAll) ;
		ON QUERYDATA QueryTest(aRows, lShowAll, .T.)
		
	END WINDOW
	
	Form_1.Center

	Form_1.Activate

Return

Function LoadItems()
Local aRows [20] [4]
	                   		               //.t.=visible, .f.=hide	
	aRows [1]	:= {'Simpson','Homer','555-5555',.t.}
	aRows [2]	:= {'Mulder','Fox','324-6432',.t.}
	aRows [3]	:= {'Smart','Max','432-5892',.t.}
	aRows [4]	:= {'Grillo','Pepe','894-2332',.f.}
	aRows [5]	:= {'Kirk','James','346-9873',.t.} 
	aRows [6]	:= {'Barriga','Carlos','394-9654',.t.} 
	aRows [7]	:= {'Flanders','Ned','435-3211',.f.} 
	aRows [8]	:= {'Smith','John','123-1234',.f.} 
	aRows [9]	:= {'Pedemonti','Flavio','000-0000',.t.} 
	aRows [10]	:= {'Gomez','Juan','583-4832',.t.} 
	aRows [11]	:= {'Fernandez','Raul','321-4332',.f.} 
	aRows [12]	:= {'Borges','Javier','326-9430',.f.}
	aRows [13]	:= {'Alvarez','Alberto','543-7898',.f.}
	aRows [14]	:= {'Gonzalez','Ambo','437-8473',.t.}
	aRows [15]	:= {'Batistuta','Gol','485-2843',.t.}
	aRows [16]	:= {'Vinazzi','Amigo','394-5983',.t.}
	aRows [17]	:= {'Pedemonti','Flavio','534-7984',.t.}
	aRows [18]	:= {'Samarbide','Armando','854-7873',.t.}
	aRows [19]	:= {'Pradon','Alejandra','???-????',.f.}
	aRows [20]	:= {'Reyes','Monica','432-5836',.f.}

Return aRows

Procedure QueryTest(aRows, lShowAll, lQuery)
	Local i, a:=0
	Default lQuery:=.F.
	FOR EACH i IN aRows
	IF i[4] .OR. lShowAll
    		a++
		IF lQuery .AND. a==This.QueryRowIndex
			This.QueryData := i [ This.QueryColIndex ]
			Return a
		ENDIF
	ENDIF
   NEXT 
Return a
Post Reply