TreeGrid - showRoot:false has no effect?

Hello, this is my code:

isc.DataSource.create({
    ID:"employees",
    dataURL:"employeeData.js",
    dataFormat:"json",
    fields: [
        {name: "idUfficio", primaryKey:true, rootValue:"0"},
        {type:"text", name: "codice", title: "Codice", width: 100},
        {type:"text", name: "descrizione", title: "Raggruppamenti CDS di competenza del Ruolo"},
        {type:"text", name: "stato", title:"Data consolidamento", width: 110},
        {name: "uffici", childrenProperty:true},
        {modelType:"children", nameProperty:"codice"}
    ]
});

isc.TreeGrid.create({
    ID: "employeeTree",
    dataSource: "employees",
    loadDataOnDemand:false,
    autoFetchData: true,
    showRoot: false,
    fields: [
        {name: "codice"},
        {name: "descrizione"},
        {name: "stato"}
    ]
    ....
});

employeeData.js:

{ idUfficio:"0", uffici: [
    {idUfficio:"4", codice:"D01", descrizione: "Direzione", stato: "Aperto", 
						uffici: [
				                {idUfficio:"188", codice:"FG23", descrizione: "Direzione", stato: "Chiuso"}
			            ]},
						{idUfficio:"5", codice:"D03", descrizione: "Vice Direzione", stato:"Aperto",
						uffici: [
				                {idUfficio:"288", codice:"HH65", descrizione: "ISPETTORATO", stato: "Aperto"},
				                {idUfficio:"289", codice:"LS67", descrizione: "RESPONSABILE", stato: "Aperto"},
			            ]},
						{idUfficio:"6", codice:"D04", descrizione: "ASSISTENZA", stato:"Aperto",
						uffici: [
				                {idUfficio:"388", codice:"PP22", descrizione: "FISCALE", stato: "Aperto"},
				                {idUfficio:"389", codice:"AD45", descrizione: "GESTIONE", stato: "Aperto"}
			            ]},
						{idUfficio:"7", codice:"D05", descrizione: "NORMATIVO", stato:"Aperto",
						uffici: [
				                {idUfficio:"488", codice:"FT65", descrizione: "RETI", stato: "Chiuso"},
				                {idUfficio:"493", codice:"IJ87", descrizione: "COMMERCIALE", stato: "Aperto"}
			            ]}
]}

I don’t want the root to show up. What am I doing wrong?

Thanks in advance

Just omit the root value from the data. For more details, see the docs for both Tree.showRoot and TreeGrid.showRoot.

sorry but I don’t understand what you mean by omitting the root value from the data.
The root in the data (employeeData.js) is
{ idUfficio:“0”, uffici: [
…

how should I write that?
Could you please provide an example?

btw, if I provide data to TreeGrid like this:
data: isc.Tree.create({
modelType: “children”,
nameProperty: “codice”,
childrenProperty: “uffici”,
root: { idUfficio: “1”, uffici: […

the root doesn’t show.

Just return the top-level “uffici” array as the data. Omit the node with idUfficio:“0”.

[
    {idUfficio:"4", codice:"D01", descrizione: "Direzione", stato: "Aperto", 
						uffici: [
				                {idUfficio:"188", codice:"FG23", descrizione: "Direzione", stato: "Chiuso"}
			            ]},
						{idUfficio:"5", codice:"D03", descrizione: "Vice Direzione", stato:"Aperto",
						uffici: [
				                {idUfficio:"288", codice:"HH65", descrizione: "ISPETTORATO", stato: "Aperto"},
				                {idUfficio:"289", codice:"LS67", descrizione: "RESPONSABILE", stato: "Aperto"},
			            ]},
						{idUfficio:"6", codice:"D04", descrizione: "ASSISTENZA", stato:"Aperto",
						uffici: [
				                {idUfficio:"388", codice:"PP22", descrizione: "FISCALE", stato: "Aperto"},
				                {idUfficio:"389", codice:"AD45", descrizione: "GESTIONE", stato: "Aperto"}
			            ]},
						{idUfficio:"7", codice:"D05", descrizione: "NORMATIVO", stato:"Aperto",
						uffici: [
				                {idUfficio:"488", codice:"FT65", descrizione: "RETI", stato: "Chiuso"},
				                {idUfficio:"493", codice:"IJ87", descrizione: "COMMERCIALE", stato: "Aperto"}
			            ]}
]

I tried that but the result is:

folder D01
  folder FG23
    folder D03
      leaf HH65
      folder LS67
        folder D04
          leaf PP22
          folder AD45
            folder D05
              leaf FT65
              leaf IJ87

instead of

folder D01
  leaf FG23
folder D03
  leaf HH65
  leaf LS67
folder D04
  leaf PP22
  LEAF AD45
folder D05
  leaf FT65
  leaf IJ87

this is what I see with root:

the structure is correct but I don’t want the root.

this is what I see if I omit the root:

no root but the structure is not what I want!
every folder became a child of the preceding leaf (which became a folder)!

this is my complete code:

isc.DataSource.create({
    ID:"employees",
    dataURL:"employeeData.js",
    dataFormat:"json",
    fields: [
        {name: "idUfficio", primaryKey:true, rootValue:"0"},
        {type:"text", name: "codice", title: "Codice", width: 220},
        {type:"text", name: "descrizione", title: "Raggruppamenti CDS di competenza del Ruolo"},
        {type:"text", name: "stato", title:"Data consolidamento", width: 110},
        {name: "uffici", childrenProperty:true},
        {modelType:"children", nameProperty:"codice"}
    ]
});

isc.TreeGrid.create({
    ID: "employeeTree",
    width: 600,
    height: 300,
    dataSource: "employees",
    loadDataOnDemand:false,
    autoFetchData: true,
    nodeIcon:"../../isomorphic/system/reference/exampleImages/icons/16/person.png",
	canSort:false,
    canResizeFields:false,
    overflow:"v-clip",
	alternateRecordStyles:true,
	showConnectors: true,
    showOpenIcons:true,
    showDropIcons:false,
    closedIconSuffix:"closed",
	canPickFields : false,
    showRoot: false,
    fields: [
        {name: "codice"},
        {name: "descrizione"},
        {name: "stato"}
    ]
});

employeeData.js:

[
    {idUfficio:"4", codice:"D01", descrizione: "Direzione", stato: "Aperto", 
			uffici: [
	                {idUfficio:"188", codice:"FG23", descrizione: "Direzione", stato: "Chiuso"}
            ]},
			{idUfficio:"5", codice:"D03", descrizione: "Vice Direzione", stato:"Aperto",
			uffici: [
	                {idUfficio:"288", codice:"HH65", descrizione: "ISPETTORATO", stato: "Aperto"},
	                {idUfficio:"289", codice:"LS67", descrizione: "RESPONSABILE", stato: "Aperto"}
            ]},
			{idUfficio:"6", codice:"D04", descrizione: "ASSISTENZA", stato:"Aperto",
			uffici: [
	                {idUfficio:"388", codice:"PP22", descrizione: "FISCALE", stato: "Aperto"},
	                {idUfficio:"389", codice:"AD45", descrizione: "GESTIONE", stato: "Aperto"}
            ]},
			{idUfficio:"7", codice:"D05", descrizione: "NORMATIVO", stato:"Aperto",
			uffici: [
	                {idUfficio:"488", codice:"FT65", descrizione: "RETI", stato: "Chiuso"},
	                {idUfficio:"493", codice:"IJ87", descrizione: "COMMERCIALE", stato: "Aperto"}
            ]}
]

well, I succeded using modelType:“parent”:

 isc.DataSource.create({
    ID:"employees",
    dataURL:"employeeData.js", 
    dataFormat:"json",
    fields: [
        {name: "idUfficio", primaryKey:true},
        {type:"text", name: "codice", title: "Codice", width: 220},
        {type:"text", name: "descrizione", title: "Raggruppamenti CDS di competenza del Ruolo"},
        {type:"text", name: "stato", title:"Data consolidamento", width: 110}
    ]
});
isc.TreeGrid.create({
    ID: "employeeTree",
    width: 600,
    height: 300,
    dataSource: "employees",
    dataProperties: {modelType: "parent",
                     rootValue: 0,
                     idField: "idUfficio",
                     parentIdField: "parentId"
                     },
    loadDataOnDemand:false,
    autoFetchData: true,
    nodeIcon:"../../isomorphic/system/reference/exampleImages/icons/16/person.png",
	canSort:false,
    canResizeFields:false,
	alternateRecordStyles:true,
	showConnectors: true,
    showOpenIcons:true,
    showDropIcons:false,
    closedIconSuffix:"closed",
	canPickFields : false,
    fields: [
        {name: "codice"},
        {name: "descrizione"},
        {name: "stato"}
    ]
});
[
    {idUfficio:"4", codice:"D01", descrizione: "Direzione", stato: "Aperto", parentId:"0"},
    {idUfficio:"188", codice:"FG23", descrizione: "Direzione", stato: "Chiuso", parentId:"4"},
	{idUfficio:"5", codice:"D03", descrizione: "Vice Direzione", stato:"Aperto", parentId:"0"},
    {idUfficio:"288", codice:"HH65", descrizione: "ISPETTORATO", stato: "Aperto", parentId:"5"},
	{idUfficio:"289", codice:"LS67", descrizione: "RESPONSABILE", stato: "Aperto", parentId:"5"},
	{idUfficio:"6", codice:"D04", descrizione: "ASSISTENZA", stato:"Aperto", parentId:"0"},
	{idUfficio:"388", codice:"PP22", descrizione: "FISCALE", stato: "Aperto", parentId:"6"},
	{idUfficio:"389", codice:"AD45", descrizione: "GESTIONE", stato: "Aperto", parentId:"6"},
	{idUfficio:"7", codice:"D05", descrizione: "NORMATIVO", stato:"Aperto", parentId:"0"},
	{idUfficio:"488", codice:"FT65", descrizione: "RETI", stato: "Chiuso", parentId:"7"},
	{idUfficio:"493", codice:"IJ87", descrizione: "COMMERCIALE", stato: "Aperto", parentId:"7"}
]

I’ll retry with children modelType after more study of SmartClient :slight_smile:

Hi Claudio,

When you got that weird tree while trying to use modelType:“children”:

  1. was the code you posted the complete code necessary to reproduce the problem?

  2. what version of SmartClient were you testing with?

  1. Yes, it is, together with this basic jsp:
<%@ page language="java"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>Raggruppamenti</title>
		<script>var isomorphicDir="../isomorphic/";</script>
		<script type="text/javascript" src="../isomorphic/system/modules/ISC_Core.js"></script>
		<script type="text/javascript" src="../isomorphic/system/modules/ISC_Foundation.js"></script>
		<script type="text/javascript" src="../isomorphic/system/modules/ISC_Containers.js"></script>
		<script type="text/javascript" src="../isomorphic/system/modules/ISC_Grids.js"></script>
		<script type="text/javascript" src="../isomorphic/system/modules/ISC_Forms.js"></script>
		<script type="text/javascript" src="../isomorphic/system/modules/ISC_DataBinding.js"></script>
		<script type="text/javascript" src="../isomorphic/skins/TreeFrog/load_skin.js"></script>
		<link href="../css/styleNew.css" rel=stylesheet type=text/css>
	</head>
	<body bgcolor="#ffffff" topmargin=0 marginheight="0">
		<div>
			<script type="text/javascript" src="../js/prova.js"></script>
		</div>
	</body>
</html>

where prova.js contains the TreeGrid and DataSource’s create method.

  1. SmartClient 6.5.1 LGPL

thanks for your patience

finally I succeded using modelType:“children” and a datasource :slight_smile:

isc.DataSource.create({
    ID:"employees",
    dataURL:"employeeData.js",
    dataFormat:"json",
    fields: [
        {name: "idUfficio"},
        {type:"text", name: "codice", title: "Codice", width: 220},
        {type:"text", name: "descrizione", title: "Raggruppamenti"},
        {type:"text", name: "stato", title:"Data", width: 110}
    ]
});
isc.TreeGrid.create({
    ID: "employeeTree",
    width: 600,
    height: 300,
    nodeIcon:"../../isomorphic/system/reference/exampleImages/icons/16/person.png",
    alternateRecordStyles:true,
    showConnectors: true,
    showOpenIcons:true,
    showDropIcons:false,
    closedIconSuffix:"closed",
    canPickFields : false,
    showRoot: false,
    fields: [
        {name: "codice"},
        {name: "descrizione"},
        {name: "stato"}
    ]
});
employees.fetchData(
    null,  
    function (response, data, request) {
        var dataTree = isc.Tree.create({
            modelType: "children",
            nameProperty: "codice",
            childrenProperty: "uffici"
        });
        dataTree.addList(data, dataTree.getRoot());
        employeeTree.setData(dataTree);
    }
);

employeeData.js

[
    {idUfficio:"4", codice:"D01", descrizione: "Direzione", stato: "Aperto", 
			uffici: [
	                {idUfficio:"188", codice:"FG23", descrizione: "Direzione", stato: "Chiuso"}
            ]},
	{idUfficio:"5", codice:"D03", descrizione: "Vice Direzione", stato:"Aperto",
			uffici: [
	                {idUfficio:"288", codice:"HH65", descrizione: "ISPETTORATO", stato: "Aperto"},
	                {idUfficio:"289", codice:"LS67", descrizione: "RESPONSABILE", stato: "Aperto"}
            ]},
	{idUfficio:"6", codice:"D04", descrizione: "ASSISTENZA", stato:"Aperto",
			uffici: [
	                {idUfficio:"388", codice:"PP22", descrizione: "FISCALE", stato: "Aperto"},
	                {idUfficio:"389", codice:"AD45", descrizione: "GESTIONE", stato: "Aperto"}
            ]},
	{idUfficio:"7", codice:"D05", descrizione: "NORMATIVO", stato:"Aperto",
			uffici: [
	                {idUfficio:"488", codice:"FT65", descrizione: "RETI", stato: "Chiuso"},
	                {idUfficio:"493", codice:"IJ87", descrizione: "COMMERCIALE", stato: "Aperto"}
            ]}
]

thanks to this thread http://forums.smartclient.com/showthread.php?t=261&highlight=tree+children+modeltype

the result:

is there a preferred modelType for trees, children vs parent? or is it only a matter of preference?

It’s a matter of preference. Someone has been assigned the task of looking at your example with modelType:“children” that wasn’t working and appeared at a glance to be correct, so we’ll let you know what was wrong.

This has been fixed in 7.0