PDA

View Full Version : loading dataIndex tree.Panel



ferchotipin
12 Jan 2012, 5:52 AM
Hi, I'm doing a really simple tree.Panel, and Im trying to use some columns but it doesnt load the dataindex apart from the 'text' one... this is the code:



var store = Ext.create('Ext.data.TreeStore', {
root : {
expanded : true,
children : [{
text : "detention",
description : 'asdfasdf',
leaf : true
}, {
text : "homework",
description : "asdfasdf",
children : [{
text : "book report",
description : 'hola',
leaf : true
}, {
text : "alegebra",
description : "haha",
leaf : true
}]

}, {
text : "buy lottery tickets",
description : "kajsdf",
leaf : true
}]
}
});


Ext.define('managerUserText', {
extend : 'Ext.tree.Panel',


initComponent : function() {
var me = this;
me.store = store;
me.fields = ['text', 'des'];
me.columns = [{
xtype : 'treecolumn',
text : 'i_Property',
dataIndex : 'text',
width : 200
}, {
text : 'i_Description',
dataIndex : 'description',
flex : 1,
width : 200
}];
me.callParent(arguments);
}
})


Thank you for any help...

mitchellsimoens
12 Jan 2012, 8:23 AM
You shouldn't use Ext.create outside of Ext.define or Ext.onReady. If you have more than one instance of this tree panel, it will share the same store.

The issue is your store didn't know about the description field:


Ext.define('managerUserText', {
extend : 'Ext.tree.Panel',
//TODO NEED AN ALIAS

initComponent : function() {
var me = this;

me.store = Ext.create('Ext.data.TreeStore', {
fields : ['text', 'description'],
root : {
expanded : true,
children : [{
text : "detention",
description : 'asdfasdf',
leaf : true
}, {
text : "homework",
description : "asdfasdf",
children : [{
text : "book report",
description : 'hola',
leaf : true
}, {
text : "alegebra",
description : "haha",
leaf : true
}]
}, {
text : "buy lottery tickets",
description : "kajsdf",
leaf : true
}]
}
});

me.columns = [{
xtype : 'treecolumn',
text : 'i_Property',
dataIndex : 'text',
width : 200
}, {
text : 'i_Description',
dataIndex : 'description',
flex : 1,
width : 200
}];

me.callParent(arguments);
}
});