I keep updating this first post with the updated version of the extension and examples (see attachment)
Extension goal:
Adding a filter to a TreePanel (API Doc style), so that you can have a TextField in the toolbar (bottom or top, depending on the cfg object passed to the TreePanelFilter
) and use it to filter the nodes in the tree.
This extension make use of the extension of the prototype of the native javascript array you can find here:
http://extjs.com/forum/showthread.php?t=37697
It has been included in the attachment.
Besides, in the example (attachment) I'm using another extension for the creation of the TreePanel (http://extjs.com/forum/showthread.ph...8#post124458);
However, the plugin works with a normal TreePanel.
Development history:
Version 1.2 alfa
****************
ADDED CLASS:
Ext.ux.SearchField as a nice clearer text field.
ADDED IN
TreePanelFilterPlugin cfg object: textFieldType, support 2 value
1) 'auto' means that the search start with the keydown event of the text field (after the buffering time)
2) 'manual' means that you need to click in the search button next to the text field or press enter when the text field has focus to start searching; default to 'manual'
ADDED FILE:
Ext.us.TreeFilterPluginAllInOne.js as a all in one solution to use the extension
Version 1.1 alfa
****************
ADDED: Ext.ux.StartWithTreeFilter class; it has the responsability to filter the nodes.
Must honour this contract interface
PHP Code:
//@Public function called before filter is applied(before the execution of the filterFn;); return true to cancel the execution of the operation.
this.beforeFilterFn = function(text, treePanel, treeFilter){
return false;
}
//@Public function called for each node on the tree starting from the root. Return true if you want to keep the node; all the nodes are processed starting from the root
this.filterFn = function(node, text, treePanel, treeFilter){
}
//@Public function called after the execution of the filterFn.
this.afterFilterFn = function(text, treePanel, treeFilter){
}
CHANGED: cfg object to pass to an instance of Ext.ux.TreeFilterPlugin (see the example)
PHP Code:
var cfg = {
toolbarPosition: //OPTIONAL @String: 'top', 'bottom', the toolbar position in which you want to add the TextField used to filter. If does not exit it will be created.
,insertAt: //OPTIONAL @Integer: the position in which you want to add the TextField filter in the toolbar.
,width: //OPTIONAL @String: TextField width.
,emptyText: //OPTIONAL @String: TextField empty text.
,label: //OPTIONAL@String: label before the text field; null or '' if you do not want to show any label.
,treeFilterCfg: //OPTIONAL @Object: TreeFilter cfg object (see API TreeFilter)
,filterInstance://OPTIONAL @Object: need to honour the contract described by Ext.ux.StartWithTreeFilter
,nodeAttribute://OPTIONAL @Object: the neame of the attribute that will be passed to the filterInstance in the filterFn
};
ATTACHMENT: in the example I'm using another extension for the creation of the TreePanel (http://extjs.com/forum/showthread.ph...8#post124458);
However, the plugin works with a normal TreePanel 
Version 1.0alfa
****************
-Initial release
By default, the plugin executes a "start with" filter on the text attribute of the node (it will be configurble).
You can pass a cfg object to an instance of TreeFilterPlugin:
PHP Code:
var cfg = {
toolbarPosition: //OPTIONAL @String: 'top', 'bottom', the toolbar position in which you want to add the TextField used to filter. If does not exit it will be created.
,insertAt: //OPTIONAL @Integer: the position in which you want to add the filter.
,width: //OPTIONAL @String: TextField width.
,emptyText: //OPTIONAL @String: TextField empty text.
,label: //OPTIONAL@String: label before the text field; null or '' if you do not want to show any label.
,treeFilterCfg: //OPTIONAL @Object: TreeFilter cfg object (see API TreeFilter)
,beforeFilterFn(text, treePanel, treeFilter): //OPTIONAL @Function called before filter is applied(before the execution of the filterFn;); return true to cancel the execution of the operation.
,filterFn(node, text, treePanel, treeFilter): //OPTIONAL @Function called for each node on the tree starting from the root.
,aftetFilterFn(text, treePanel, treeFilter): //OPTIONAL@Function called after filter after the execution of the filterFn.
,filterFnScope: //OPTIONAL @Object: the scope of the filterFn function, default the current node.
};
Public methods:
PHP Code:
//@Return the inner TreeFilter instance.
getTreeFilter()
//@Return the inner TextField instance.
getTextField()
//@clear the filter and the value of the TextField
clearFilter():
****************
Examples and explanations:
Simply, add the plugin to a TreePanel:
PHP Code:
var treeFilterPlugin = new Ext.ux.TreeFilterPlugin({
toolbarPosition:'top'
,width: '170'
,label: 'Start with: '
});
treePanel = new Ext.tree.TreePanel({
title: 'Users',
...
plugins: [treeFilterPlugin]
});
Cheers