PDA

View Full Version : Data.TreePAnel



fvinson
25 Sep 2012, 11:57 AM
I have a Store for Tree : Data.Treestore the proxy is a xml file
I create TreePanel with the TreeStore
In the xml, i have more information for all children ; for exemple i have a tag <description>blabla</decription> in witch i have information. i want to get the information in console.log
<treemenu>
<text>.<text>
<children>
<text>TEST<text>
<leaf>true</leaf>
<id>1<id>
<description>blabla</decription>
</children>
</treemenu>

wheni click on TEST i have id information :record.get('id') but i can't have information on decription
i think it is necesary to add new field information in store but i don't know how to make this

Thank you

vietits
25 Sep 2012, 3:07 PM
What do your model and store look like?

fvinson
26 Sep 2012, 12:09 AM
i don't have a specific model ; i use data.TreeStore


var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'xml2json.php',
reader: {type: 'json'}
},
root: {
text : 'Exemples'
}
});

// create the Tree
var treePanel = Ext.create('Ext.tree.Panel', {
store: store,

fvinson
26 Sep 2012, 12:36 AM
I resolve my problem with adding fields in model

Ext.define('treeExamples', {
extend: 'Ext.data.Model',
fields: [
'text','id','children',
{name: 'description', mapping: 'description'},
{name: 'src', mapping: 'src'}
]
});
var store = Ext.create('Ext.data.TreeStore', {
model: 'treeExamples',
....

Thank you

vietits
26 Sep 2012, 12:48 AM
You should use fields config to include fields in your data.


var store = Ext.create('Ext.data.TreeStore', {
fields: ['id','text','description'],
proxy: {
type: 'ajax',
url: 'xml2json.php',
reader: {type: 'json'}
},
root: {
text : 'Exemples'
}
});