Page 1 of 1

I need to create something like tree combined with grid

Posted: Mon Dec 17, 2018 11:48 am
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?

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

Posted: Mon Dec 17, 2018 2:49 pm
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

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

Posted: Mon Dec 17, 2018 5:33 pm
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

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

Posted: Mon Dec 17, 2018 6:31 pm
by mol
I'm trying to get similat effect with virtualgrid.
My application must run on 32 bit :-(

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

Posted: Tue Dec 18, 2018 2:27 am
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

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

Posted: Tue Dec 18, 2018 8:36 am
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


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

Posted: Tue Dec 18, 2018 3:58 pm
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

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

Posted: Wed Dec 19, 2018 6:00 pm
by Rathinagiri
If your requirement is to just show data, you can use HTML Table and HTML Control.

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

Posted: Thu Dec 20, 2018 6:45 am
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.

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

Posted: Thu Dec 20, 2018 11:14 pm
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