PDA

View Full Version : Filter the menu - like using Ext.tree.TreeFilter



fabiojpoli
25 Oct 2010, 11:19 AM
Good afternoon,

So for know that there ux, http://remotetree.extjs.eu/
But given that this class has Ext: http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeFilter, I would use it. Am doing as below, though occurs as follows Error:


startNode is undefined

Line 33765


var af = this.filtered, rv = this.reverse;
33750 var f = function(n){
33751 if(n == startNode){
33752 return true;
33753 }
33754 if(af[n.id]){
33755 return false;
33756 }
33757 var m = fn.call(scope || n, n);
33758 if(!m || rv){
33759 af[n.id] = n;
33760 n.ui.hide();
33761 return false;
33762 }
33763 return true;
33764 };
33765 startNode.cascade(f); //ERROR
33766 if(this.remove){
33767 for(var id in af){
33768 if(typeof id != "function"){
33769 var n = af[id];
33770 if(n && n.parentNode){
33771 n.parentNode.removeChild(n);
33772 }
33773 }
33774 }
33775 }

'm Forgetting some property?


this.hiddenPkgs = [];

this.menuAjuda = new Ext.tree.TreePanel({
tbar:[{
xtype: 'textfield',
width: 145,
emptyText:'Procurar',
enableKeyEvents: true,
listeners:{
scope: this,
render: function(f){
this.filter = new Ext.tree.TreeFilter(this, {
clearBlank: true,
autoClear: true
});
},
keydown: {
fn: this.filterTree,
buffer: 350,
scope: this
}
}
}],
region: 'west',
width: 150,
split: true,
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
//border: false,
dataUrl: 'help/menuAjuda.json',
rootVisible: false,
root: {nodeType: 'async'},
listeners: {
scope: this,
render: function(tp){
tp.getSelectionModel().on('selectionchange', function(tree, node){
var el = this.conteudoAjuda.body;
if(node && node.leaf){
tpl.overwrite(el, node.attributes);
}else{
el.update(detailsText);
}
}, this)
}
}
});


filterTree: function(t, e){
var text = t.getValue();
Ext.each(this.hiddenPkgs, function(n){
n.ui.show();
});
if(!text){
this.filter.clear();
return;
}
this.menuAjuda.expandAll();

var re = new RegExp('^' + Ext.escapeRe(text), 'i');
this.filter.filterBy(function(n){
//return !n.attributes.isClass || re.test(n.text);
});

// hide empty packages that weren't filtered
this.hiddenPkgs = [];
var me = this;
/*this.root.cascade(function(n){
if(!n.attributes.isClass && n.ui.ctNode.offsetHeight < 3){
n.ui.hide();
me.hiddenPkgs.push(n);
}
});*/
}

I appreciate if someone can help me.

Hug!