3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.tree.TreeFilter"></div>/**
9 * @class Ext.tree.TreeFilter
10 * Note this class is experimental and doesn't update the indent (lines) or expand collapse icons of the nodes
11 * @param {TreePanel} tree
12 * @param {Object} config (optional)
14 Ext.tree.TreeFilter = function(tree, config){
17 Ext.apply(this, config);
20 Ext.tree.TreeFilter.prototype = {
26 <div id="method-Ext.tree.TreeFilter-filter"></div>/**
27 * Filter the data by a specific attribute.
28 * @param {String/RegExp} value Either string that the attribute value
29 * should start with or a RegExp to test against the attribute
30 * @param {String} attr (optional) The attribute passed in your node's attributes collection. Defaults to "text".
31 * @param {TreeNode} startNode (optional) The node to start the filter at.
33 filter : function(value, attr, startNode){
34 attr = attr || "text";
36 if(typeof value == "string"){
37 var vlen = value.length;
38 // auto clear empty filter
39 if(vlen == 0 && this.clearBlank){
43 value = value.toLowerCase();
45 return n.attributes[attr].substr(0, vlen).toLowerCase() == value;
47 }else if(value.exec){ // regex?
49 return value.test(n.attributes[attr]);
52 throw 'Illegal filter type, must be string or regex';
54 this.filterBy(f, null, startNode);
57 <div id="method-Ext.tree.TreeFilter-filterBy"></div>/**
58 * Filter by a function. The passed function will be called with each
59 * node in the tree (or from the startNode). If the function returns true, the node is kept
60 * otherwise it is filtered. If a node is filtered, its children are also filtered.
61 * @param {Function} fn The filter function
62 * @param {Object} scope (optional) The scope of the function (defaults to the current node)
64 filterBy : function(fn, scope, startNode){
65 startNode = startNode || this.tree.root;
69 var af = this.filtered, rv = this.reverse;
77 var m = fn.call(scope || n, n);
88 if(typeof id != "function"){
90 if(n && n.parentNode){
91 n.parentNode.removeChild(n);
98 <div id="method-Ext.tree.TreeFilter-clear"></div>/**
99 * Clears the current filter. Note: with the "remove" option
100 * set a filter cannot be cleared.
104 var af = this.filtered;
106 if(typeof id != "function"){