Grid and hierarchical view in V8

Hi all,

After a period I’ve just started to use SC again and in particular V8 . I got an instant question… (hole in my memory…)
I have a table where I got the field ID and the ParentID just to define a hierarchy on the same table.
Every record has its own parent starting from level 0

I have to represent it on a grid and I would like to see the different levels grouped with the + icon on the beginning to open the level.
I got three level so I need also that the second level has the + icon in front of the sub row…

  • LEVEL 0 ID
    ----------LEVEL 01 ID
    ----------+ LEVEL 02 ID
    --------------------LEVEL 021 ID
    --------------------LEVEL 022 ID

    I don’t remember how to produce such kind of grid. Need I to organize it as nested grid ? Of the same table ??? Not possible I suppose
    Many thanks
    Jovannino

sc1.jpg

I think you can to do a grid with details.

If I’m not wrong details show you the record detail only.
I need to see all hierarchy before to arrive to record level.
It’s like a master details view but I need more levels that two.

I’m trying to use Grid and Nested Grid but I’ve still problems

Hi ,
after some tests… this is what I’ve done. Grid and Nested Grid . See image

I need now to hide the second level of hierarchy on main grid becouse it’s correctly present on its parent detail
How can it do ??
Thanks

sc01.jpg

I needed some time ago the same, but i created a menu nested from a table recursive.
Would be good id SC Team helps with this, because is very necesary for our work.
Attach image from my menu.

sc_recursive.PNG

Hi Alvagar,

Very nice !!! How did you build it ?

I did … in some way , adding a where clause but I’m not satisfied…

sc1.jpg

I did it with a table recursive. I hope can help you.

You must change the SQL and fields name

First All you must create a TREE MENU with SC
(for example: treemenu_agr)

THEN CREATE A PHP METHOD: GetChilds with parameters:
menu by reference
sql by value
codefather by value

This is code for GetChilds :

sc_lookup(rs_child, $sql.$codefather. " order by agr_nmbre");
		foreach({rs_child} as $agr_child)
		{
			$agr_cdgo	= $agr_child[0];
			$agr_cdgop 	= $agr_child[1];
			$agr_nmbre 	=  $agr_cdgo."-".$agr_child[2];

			sc_appmenu_add_item($menu,"$agr_cdgo","$codefather",$agr_nmbre,form_agr_tree,neg_cdgo=[neg_cdgo];agr_cdgo=$agr_cdgo,);
			getChilds($menu, $sql, $agr_cdgo );
		}

ONLOAD EVENT

// Get params from a app.
if(isset($_POST[‘nmgp_parms’]) && substr($_POST[‘nmgp_parms’], 0, 10)==“v_agr_cdgo” && isset([v_agr_cdgo]) && !empty([v_agr_cdgo]))
{
$agr_cdgo_parm = [v_agr_cdgo];
}

$menu = “treemenu_agr”;
//-------------------------------------------------------------------------
sc_appmenu_reset($menu);
sc_appmenu_create($menu);
//-------------------------------------------------------------------------

$sql_root = “select agr_cdgo, agr_cdgop, agr_nmbre from agr_agrpcion where neg_cdgo = “.[neg_cdgo].” and agr_cdgop is null order by agr_nmbre”;
$sql_child = "select agr_cdgo, agr_cdgop, agr_nmbre from agr_agrpcion where agr_cdgop = ";
sc_lookup(rs_root, $sql_root);

$items = false;

foreach({rs_root} as $agr_root)
{
$items = true;
$agr_cdgo = $agr_root[0];
$agr_cdgop = $agr_root[1];
$agr_nmbre = $agr_cdgo."-".$agr_root[2];

//sc_appmenu_add_item(“String Menu_Name”, “Id_Item”, “Id_Parent”, “Label”, “Aplication”, “Parameters”, “Icon”, “Hint”, “Target”)
sc_appmenu_add_item($menu,"$agr_cdgo",$agr_nmbre,form_agr_tree,neg_cdgo=[neg_cdgo];agr_cdgo=$agr_cdgo);
getChilds($menu, $sql_child, $agr_cdgo);

}

if(!$items) {
sc_redir(form_agr, neg_cdgo=[neg_cdgo];agr_cdgo=0, “$menu”);
}

WOWWWWWW !!! Good job !!! Not a piece of cake… ;-(

Ok. Giovannino. I Hope that helps.

Hi Alvagar,
I trying to do a hierarchy structure and can you please share some info with me. How can I get in touch with you? Thanks and look forward to you reply

Hi clarence.
This is the Recursive table:
image

Thanks and will look into it.