Reputation: 3932
In my data.json file I have static data which is to be loaded in the treepanel.According to this link reference, I have changed "children" to "data".But still I am not geting data in my tree panel grid.
My data.json file
{
"data":
[
{
"App": "active"
"iconCls":"task-folder",
"expanded":"false",
"data": [
{
"AppReport1": "active",
"leaf": "true"
}
]
}
]
}
Here Is what I am doing:
initComponent: function () {
var me = this;
Ext.log("initComponent()", me);
me.treeStore = Ext.create("Ext.data.TreeStore", {
proxy: {
type: "ajax",
model : 'EPH.model.DBStatusModel',
autoLoad: true,
type: 'ajax',
url:'app/data/data.json',
reader: {
type: 'json',
root : 'data'
}
},
root: {
expanded: true
}
});
this.down('treepanel').setRootNode(store.getRootNode());
}
I think I have problem in my data.json file.Is it correct or do I need to change something.Please help me out resolving this issue.Thanks.
Upvotes: 1
Views: 1765
Reputation: 770
Childen it's a important part of configuration for Node interface.
Sencha api: children
This config param say you what data root node has.
EDIT:
and what happend with "defaultRootProperty":
Sencha api: treeStore
For the tree to read nested data, the Ext.data.reader.Reader must be configured with a root property, so the reader can find nested data for each node (if a root is not specified, it will default to 'children'). This will tell the tree to look for any nested tree nodes by the same keyword, i.e., 'children'. If a root is specified in the config make sure that any nested nodes with children have the same name. Note that setting defaultRootProperty accomplishes the same thing.
Upvotes: 1
Reputation: 1746
In the reference link the first data appears to be JSON Object and in your JSON file is an JSON Array. I think this it should look.
{
"data": //root
{
"data"://children
[
{
"App": "active"
"iconCls":"task-folder",
"expanded":"false",
"data": [
{
"AppReport1": "active",
"leaf": "true"
}
]
}
]
}
}
Note: This code was taken from the original JSON file of the author.
Upvotes: 1