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: 3248
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 231 times
Been thanked: 132 times
Contact:

I need to create something like tree combined with grid

Post by mol » Mon Dec 17, 2018 11:48 am

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: 1177
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 36 times
Been thanked: 83 times
Contact:

Post by andyglezl » Mon Dec 17, 2018 2:49 pm

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: 656
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Has thanked: 1 time
Been thanked: 61 times

Post by EduardoLuis » Mon Dec 17, 2018 5:33 pm

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: 3248
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 231 times
Been thanked: 132 times
Contact:

Post by mol » Mon Dec 17, 2018 6:31 pm

I'm trying to get similat effect with virtualgrid.
My application must run on 32 bit :-(

User avatar
andyglezl
Posts: 1177
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 36 times
Been thanked: 83 times
Contact:

Post by andyglezl » Tue Dec 18, 2018 2:27 am

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: 506
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 137 times
Been thanked: 422 times

Post by edk » Tue Dec 18, 2018 8:36 am

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: 3248
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 231 times
Been thanked: 132 times
Contact:

Post by mol » Tue Dec 18, 2018 3:58 pm

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: 5264
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Wed Dec 19, 2018 6:00 pm

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: 3248
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 231 times
Been thanked: 132 times
Contact:

Post by mol » Thu Dec 20, 2018 6:45 am

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: 506
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 137 times
Been thanked: 422 times

Post by edk » Thu Dec 20, 2018 11:14 pm

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