Hey All,
I have defined a TreeCombo. The combo is supposed to get a string(which contains some nodes) and then mark those nodes as checked, but I cannot get a node using getNodeById().
Below is part of the TreeCombo code.
Plz help.
Here is the part code of treeComboBox.
Code:
Ext.define('xxx.TreeComboBox', {
extend: 'Ext.form.field.ComboBox',
url: '',
tree: {},
textProperty: 'text',
valueProperty: '',
initComponent: function () {
Ext.apply(this, {
editable: false,
queryMode: 'local',
select: Ext.emptyFn
});
this.displayField = this.displayField || 'text',
this.treeid = Ext.String.format('tree-combobox-{0}', Ext.id());
this.tpl = Ext.String.format('<div id="{0}"></div>', this.treeid);
if (this.url) {
var me = this;
Ext.create('Ext.data.TreeStore', {
storeId: 'treeComboStore',
autoLoad: true,
sorters: [
{
property: 'leaf',
direction: 'ASC'
},
{
property: 'text',
direction: 'ASC'
}
],
folderSort: true,
proxy: {
type: 'ajax',
url: this.url
},
fields: [
{name: 'text', type: 'string'},
{name: 'id', type: 'string'}
]
});
this.tree = Ext.create('Ext.tree.Panel', {
rootVisible: false,
autoScroll: true,
height: 200,
store: 'treeComboStore'
});
this.tree.on('itemclick', function (undefined, record) {
me.checkChildren(record, !record.get('checked'));
me.checkParent(record, record.get('checked'));
me.setValue(me.getSelectedValue(me.tree.getRootNode()));
});
Here is the code to create the treeCombo.
Code:
var treeCombo = Ext.create('xxx.TreeComboBox', {
id: 'treecombo',
fieldLabel: param,
renderTo: 'treeCombo',
width: 250,
url: '......json'
});
treeCombo.setValue(checkedItem);
var items = checkedItem.split(',');
var treeStore = Ext.data.StoreManager.lookup('treeComboStore');
for(var i=0;i<items.length;i++){
var record = treeStore.getNodeById(items[i]);
alert("record = "+record.get('text'));
treeCombo.fireEvent('itemclick',this,record);
}