3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.1
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.tree.TreeFilter"></div>/**
16 * @class Ext.tree.TreeFilter
17 * Note this class is experimental and doesn't update the indent (lines) or expand collapse icons of the nodes
18 * @param {TreePanel} tree
19 * @param {Object} config (optional)
21 Ext.tree.TreeFilter = function(tree, config){
24 Ext.apply(this, config);
27 Ext.tree.TreeFilter.prototype = {
33 <div id="method-Ext.tree.TreeFilter-filter"></div>/**
34 * Filter the data by a specific attribute.
35 * @param {String/RegExp} value Either string that the attribute value
36 * should start with or a RegExp to test against the attribute
37 * @param {String} attr (optional) The attribute passed in your node's attributes collection. Defaults to "text".
38 * @param {TreeNode} startNode (optional) The node to start the filter at.
40 filter : function(value, attr, startNode){
41 attr = attr || "text";
43 if(typeof value == "string"){
44 var vlen = value.length;
45 // auto clear empty filter
46 if(vlen == 0 && this.clearBlank){
50 value = value.toLowerCase();
52 return n.attributes[attr].substr(0, vlen).toLowerCase() == value;
54 }else if(value.exec){ // regex?
56 return value.test(n.attributes[attr]);
59 throw 'Illegal filter type, must be string or regex';
61 this.filterBy(f, null, startNode);
64 <div id="method-Ext.tree.TreeFilter-filterBy"></div>/**
65 * Filter by a function. The passed function will be called with each
66 * node in the tree (or from the startNode). If the function returns true, the node is kept
67 * otherwise it is filtered. If a node is filtered, its children are also filtered.
68 * @param {Function} fn The filter function
69 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function is executed. Defaults to the current Node.
71 filterBy : function(fn, scope, startNode){
72 startNode = startNode || this.tree.root;
76 var af = this.filtered, rv = this.reverse;
84 var m = fn.call(scope || n, n);
95 if(typeof id != "function"){
97 if(n && n.parentNode){
98 n.parentNode.removeChild(n);
105 <div id="method-Ext.tree.TreeFilter-clear"></div>/**
106 * Clears the current filter. Note: with the "remove" option
107 * set a filter cannot be cleared.
111 var af = this.filtered;
113 if(typeof id != "function"){