How to work with treecombo in Extjs 4.1
combobox, extjs, extjs4.1, tree
Solution
To solve your second problem, you need to specify the root node when creating the tree store.
var treestore = Ext.create('Ext.data.TreeStore', {
root: {
text: 'Root',
id: '0'
},
proxy: {
type: 'ajax',
url: 'example.php',
reader: {
type: 'json'
}
},
autoload: true
});
Also, I should mention that the variable name you used for the tree store in the jsfiddle example is storeMenu rather than treestore. So if you want to replace the static tree store with the ajax version, make sure you are using the correct variable name.
Problem
I found tutor in http://www.sencha.com/forum/showthread.php?198856-Ext.ux.TreeCombo I try to make a treecombo in Extjs4.1 in http://jsfiddle.net/rq2ha/ here is my code ``` Ext.onReady(function() { Ext.create('Ext.ux.TreeCombo', { margin:10, width:120, height: 10, treeHeight: 10, treeWidth: 240, renderTo: 'treecombo3', store: storeMenu, selectChildren: false, canSelectFolders: true ,itemTreeClick: function(view, record, item, index, e, eOpts, treeCombo) { var id = record.data.id; // I want to do something here. // But combo do nothing (not selected item or not finish) when i init itemTreeClick function } }); }); ``` 1st problem: I want to get id of tree and do something When i click item of tree on combo. But combo not complete (seleted) when i click (combo do nothing). 2nd problem: if i change store is dynamic like ``` var treestore = Ext.create('Ext.data.TreeStore', { proxy: { type: 'ajax', url: 'example.php', reader: { type: 'json' } }, autoload: true }); ``` I will get error my json ``` [ { id : '1' , text : 'a', iconCls: 'cls1' ,children :[{ id : '2' , text : 'b', iconCls: 'cls2' ,children :[{ id : '9' , text : 'a', iconCls: 'cls' ,children :[]},{ id : '14' , text : 'a', iconCls: 'c' ,children :[{ id : '33' , text : 'b', iconCls: 'cls' ,children :[{ id : '35' , text : 'a', iconCls: 'cls' ,children :[{ id : '36' , text : 'a', iconCls: 'cls' ,children :[]}]}]}]},{ id : '16' , text : 'd', iconCls: 'cls' ,leaf:true}]},... ``` How can i fix that thank