3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.tree.TreeFilter"></div>/**
10 * @class Ext.tree.TreeFilter
11 * Note this class is experimental and doesn't update the indent (lines) or expand collapse icons of the nodes
12 * @param {TreePanel} tree
13 * @param {Object} config (optional)
15 Ext.tree.TreeFilter = function(tree, config){
18 Ext.apply(this, config);
21 Ext.tree.TreeFilter.prototype = {
27 <div id="method-Ext.tree.TreeFilter-filter"></div>/**
28 * Filter the data by a specific attribute.
29 * @param {String/RegExp} value Either string that the attribute value
30 * should start with or a RegExp to test against the attribute
31 * @param {String} attr (optional) The attribute passed in your node's attributes collection. Defaults to "text".
32 * @param {TreeNode} startNode (optional) The node to start the filter at.
34 filter : function(value, attr, startNode){
35 attr = attr || "text";
37 if(typeof value == "string"){
38 var vlen = value.length;
39 // auto clear empty filter
40 if(vlen == 0 && this.clearBlank){
44 value = value.toLowerCase();
46 return n.attributes[attr].substr(0, vlen).toLowerCase() == value;
48 }else if(value.exec){ // regex?
50 return value.test(n.attributes[attr]);
53 throw 'Illegal filter type, must be string or regex';
55 this.filterBy(f, null, startNode);
58 <div id="method-Ext.tree.TreeFilter-filterBy"></div>/**
59 * Filter by a function. The passed function will be called with each
60 * node in the tree (or from the startNode). If the function returns true, the node is kept
61 * otherwise it is filtered. If a node is filtered, its children are also filtered.
62 * @param {Function} fn The filter function
63 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function is executed. Defaults to the current Node.
65 filterBy : function(fn, scope, startNode){
66 startNode = startNode || this.tree.root;
70 var af = this.filtered, rv = this.reverse;
78 var m = fn.call(scope || n, n);
89 if(typeof id != "function"){
91 if(n && n.parentNode){
92 n.parentNode.removeChild(n);
99 <div id="method-Ext.tree.TreeFilter-clear"></div>/**
100 * Clears the current filter. Note: with the "remove" option
101 * set a filter cannot be cleared.
105 var af = this.filtered;
107 if(typeof id != "function"){