PDA

View Full Version : Map fields in TreePanel



catnipper
29 Sep 2016, 8:07 AM
I have trouble to find the proper way how to map fields in the datasource to my treePanel.
My datasource looks like:

[{
„label":"CEE-Material“,
"id":"2“,
"cls":"xxx“,
"style":“folder"
}]

I wrote the following code trying to map "label" to "text" (as you can see I tried to map pretty much everywhere...) - without success :-?

var CometProductTree = Ext.tree;
var CometProductTreeLoader = new CometProductTree.TreeLoader({
dataUrl:'/plugin/comet/data/getMaster.php',
baseParams: {
server: this.server,
port: this.port,
user: this.user,
database: this.database,
language: this.language,
country: this.country,
method: 'get',
what: 'productsTree'
},
fields : [
{ name: 'id', type:'string',mapping: 'id'},
{ name: 'text', type: 'string', mapping: 'label'}
]
});
CometProductTreePanel = new CometProductTree.TreePanel({
animate:true,
autoScroll:true,
loader: CometProductTreeLoader,
enableDD:true,
containerScroll: true,
border: false,
width: 300,
height: '200',
dropConfig: {appendOnly:true},
fields : [
{ name: 'id', type:'string',mapping: 'id'},
{ name: 'text', type: 'string', mapping: 'label'}
],
listeners: {
/*expandnode: function(n) {
console.log('expandnode: "' + n.attributes.text + '"');
},*/
beforeload: function(n) {
// console.log('beforeload (node): "' + n.attributes.id + '"');
CometProductTreeLoader.baseParams.id = n.attributes.id;
}
}
});
var CometProductTreeRoot = new CometProductTree.AsyncTreeNode({
expanded: true,
text: 'Produktrecherche',
draggable:false,
id: this.id,
loader: CometProductTreeLoader,
fields : [
{ name: 'id', type:'string',mapping: 'id'},
{ name: 'text', type: 'string', mapping: 'label'}
]
});
CometProductTreePanel.setRootNode(CometProductTreeRoot);