Hi everybody,
The request returns me this JSON:
My tree panel :
And my model :
I don't know how to use 'idProperty' in the model, how to config my treepanel, and how to config the treestore.
[Ext 5.0.1] TreeStore need help
I'am trying to use extjs 5 instead of extjs 4.2 for my new project.
I already built a treepanel with extjs 4.2 in this project and now i don't understand how it works in extjs 5 or what i did wrong in extjs 4. I tried to find something to help me since one week but i failed.
My problem is i can't populate my treepanel with my treestore by a json request.
The request is loaded but i think the data doesn't go in the store (storeTree.getCount() return 0).
I replace the root by a rootProperty but i think it's not enough.
I show you the code:
Code:
var storeTree = Ext.create('Ext.data.TreeStore', {
model: 'ArboModel',
root: {
id: 1
},
defaultRootId: '',
proxy: {
type: 'ajax',
reader: {
type: 'json',
rootProperty: 'root'
},
url: url
},
lazyFill: true
});
storeTree.load({
params: {
node: 'root'
}
});
storeTree.on('load', function () {
// console.log(storeTree);
alert(storeTree.getCount());
});
The request returns me this JSON:
Code:
{"root":[{"children":[{"class":"models.Folder","entityId":2,"id":2,"idDoc":null,"leaf":false,"persistent":true,"text":"DRH"}],"class":"models.Folder","entityId":1,"id":1,"idDoc":null,"leaf":false,"persistent":true,"text":"UNILEVER"}]}
My tree panel :
Code:
var treeArboEnterpriseTree = Ext.create('Ext.tree.Panel', {
title: 'Arborescence',
width: 300,
flex: 1,
height: 250,
xtype: 'treegrid',
store: storeTree,
rootVisible: false,
collapsible: true
});
And my model :
Code:
Ext.define('ArboModel', { extend: 'Ext.data.TreeModel',
idProperty :'id',
fields: [
{
name: 'id',
type : 'int'
},{
name: 'leaf',
type : 'boolean'
}, {
name : 'libelle',
type : 'string'
},{
name : 'text',
type : 'string'
},{
name : 'children'
},{
name : 'idDoc',
type : 'int'
}
]
});
I don't know how to use 'idProperty' in the model, how to config my treepanel, and how to config the treestore.
Thank you for helping !
Pierre
[Ext 5.0.1] TreeStore need help
Aucun commentaire:
Enregistrer un commentaire