PDA

View Full Version : TreeCombo expand tree problem



nohaapav
12 Mar 2013, 5:50 AM
Hi guys,

i have a problem with calling list.expandAll() function in my treecombo ..
Basically i'm reloading data in treecombo based on string like some kind of filter -> check code



doQuery: function(q, forceAll) {
if(q.length >= this.minChars){
this.loadFilteredTree(q);
this.expandTree();
}
},

loadFilteredTree: function(q) {
this.list.getLoader().dataUrl = 'productMasterData/getMasterDataByContractId/'+q
if(hasReload){
this.list.getLoader().load(this.list.root);
}
this.list.expandAll();
},

expand : function(){
if(this.isExpanded() || !this.hasFocus){
return;
}
this.list.alignTo.apply(this.list, [this.el].concat(this.listAlign));
this.list.show();
if(Ext.isGecko2){
this.innerList.setOverflow('auto');
}
this.mon(Ext.getDoc(), {
scope: this,
mousewheel: this.collapseIf,
mousedown: this.collapseIf
});
this.fireEvent('expand', this);
},

expandTree: function() {
if (!this.list.rendered) {
this.list.render(document.body);
this.innerList = this.list.body;;
this.list.hide();
}

this.el.focus();
this.expand.apply(this,arguments);
},


The problem is that if i load the data first time in grid all the nodes are expanded correctly, but only for that first shot. If i reload once more only the first level is expanded(not all 3 levels which i have in my tree) .. Any idea why ?

nohaapav
13 Mar 2013, 6:51 AM
i was able to solve it by myself + i see awesome loaders gif now either :)



doQuery: function(q, forceAll) {
if(q.length >= this.minChars){
this.loadFilteredTree(q);
this.expandTree();
this.list.expandAll();
}
},

loadFilteredTree: function(q) {
this.preloadTree();
var id = this.parentData.id
var complexId = id.concat('.'+q)
this.list.getLoader().dataUrl = this.treeController.concat(complexId);
this.isSwitched = true
},

preloadTree: function(){
this.list.root.childRendered = false
this.list.root.expanded = true
this.list.root.loaded = false
this.list.root.loading = false
},


Anyway guys is there any function to expand only root .. something like expandAll() but like expandRoot() :)

Thx ..

nohaapav
13 Mar 2013, 7:02 AM
Sorry .. im probably blind as hell ..

there is of course this.list.getRootNode().expand(); :))