PDA

View Full Version : Tree Panel with rootVisible true does not show root data in grid (have fiddle ex)



SteveGlymph
10 Jun 2015, 5:28 AM
ExtJS 4.2.2

I've taken the guts of the code I'm working with and stripped it down in a fiddle example to show the problem I'm having.

Fiddle link: https://fiddle.sencha.com/#fiddle/oa1 (https://fiddle.sencha.com/#fiddle/oa1)

So when I set rootVisible : true the root entry is shown with the expandable icon in the table BUT the data associated with the node is not visible. I don't know if it's the data format or some configuration I'm missing.

Thanks for any help.


52622

Jad
10 Jun 2015, 6:12 AM
Hello,Your root node doesn't have fields name and level


Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: {
xtype : 'myTreeView',
itemId : 'netVisTreeView',
layout : 'fit'
}
});

var treeView = Ext.ComponentQuery.query('myTreeView')[0];

treeView.store.load({
callback: function () { console.log('hello', treeView.store.getRootNode().getData()); }
});

SteveGlymph
10 Jun 2015, 6:41 AM
Hey thanks for your reply. Maybe I don't understand the format that's needed for the data but here is a subset of the data showing what I believe is the root node. It contains a name and level (I've have the name set to "rootNode" for convenience)

Do you see anything wrong with this format?

{
"name": "rootNode",
"level": 0,
"leaf": "false",
"children": [

{
"name": "1000150",
"level": 1,
"leaf": "false",
"children": [


{


"name": "1000151",
"level": 2,
"leaf": "false",
"children": [


{


"name": "1000152",
"level": 3,
"leaf": "true"

}

]
}

]

}, ...... More data is in the data1.json file.

SteveGlymph
11 Jun 2015, 9:44 AM
Scott Martin on June 11, 2015, 9:52 a

Ext 4.x TreeStore is not really a store. It's just a holder of a root, and a vehicle for loading remote children. In Ext5 it has been unified with Ext.data.Store.

Basically you have to set the root as a config that calls setRootNode() to create it for you. ( or make call to set )

Here is simple explanation I like to refer to by vietits in the forums:
https://www.sencha.com/forum/showthread.php?183569

In your case, I modified the JSON to and set rootVisible to false.

Scott.



Scott Martin on June 11, 2015, 12:32 pm
I confirmed this with Engineering.

The root node always has to be present for data to load. Since the load process relies on the node to exist, it cannot be defined by the initial data load.
So the solution is to use the default ( blank ), create one with a config / setRootNode() .. hard coded, or hide the default and load children, hence the need for extra node.

I referenced the example as the data is simple and quick to understand.

I do believe this could be explained better in the docs. I will see what I can do to get this updated.

Regards,
Scott.

So one solution was to change the data as follows and set rootVisible to false:
{"text":".",
"children": [
{
"name": "rootNode",
"level": 0,
"leaf": "false",
"expanded": true,
"children": [