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.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
15 <div id="cls-Ext.ux.grid.filter.StringFilter"></div>/**
16 * @class Ext.ux.grid.filter.StringFilter
17 * @extends Ext.ux.grid.filter.Filter
18 * Filter by a configurable Ext.form.TextField
19 * <p><b><u>Example Usage:</u></b></p>
21 var filters = new Ext.ux.grid.GridFilters({
30 active: true, // default is false
31 iconCls: 'ux-gridfilter-text-icon' // default
32 // any Ext.form.TextField configs accepted
37 Ext.ux.grid.filter.StringFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
39 <div id="cfg-Ext.ux.grid.filter.StringFilter-iconCls"></div>/**
40 * @cfg {String} iconCls
41 * The iconCls to be applied to the menu item.
42 * Defaults to <tt>'ux-gridfilter-text-icon'</tt>.
44 iconCls : 'ux-gridfilter-text-icon',
46 emptyText: 'Enter Filter Text...',
52 * Template method that is to initialize the filter and install required menu items.
54 init : function (config) {
56 enableKeyEvents: true,
57 iconCls: this.iconCls,
60 keyup: this.onInputKeyUp
64 this.inputItem = new Ext.form.TextField(config);
65 this.menu.add(this.inputItem);
66 this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);
71 * Template method that is to get and return the value of the filter.
72 * @return {String} The value of this filter
74 getValue : function () {
75 return this.inputItem.getValue();
80 * Template method that is to set the value of the filter.
81 * @param {Object} value The value to set the filter
83 setValue : function (value) {
84 this.inputItem.setValue(value);
85 this.fireEvent('update', this);
90 * Template method that is to return <tt>true</tt> if the filter
91 * has enough configuration information to be activated.
94 isActivatable : function () {
95 return this.inputItem.getValue().length > 0;
100 * Template method that is to get and return serialized filter data for
101 * transmission to the server.
102 * @return {Object/Array} An object or collection of objects containing
103 * key value pairs representing the current configuration of the filter.
105 getSerialArgs : function () {
106 return {type: 'string', value: this.getValue()};
109 <div id="method-Ext.ux.grid.filter.StringFilter-validateRecord"></div>/**
110 * Template method that is to validate the provided Ext.data.Record
111 * against the filters configuration.
112 * @param {Ext.data.Record} record The record to validate
113 * @return {Boolean} true if the record is valid within the bounds
114 * of the filter, false otherwise.
116 validateRecord : function (record) {
117 var val = record.get(this.dataIndex);
119 if(typeof val != 'string') {
120 return (this.getValue().length === 0);
123 return val.toLowerCase().indexOf(this.getValue().toLowerCase()) > -1;
128 * Handler method called when there is a keyup event on this.inputItem
130 onInputKeyUp : function (field, e) {
132 if (k == e.RETURN && field.isValid()) {
134 this.menu.hide(true);
138 this.updateTask.delay(this.updateBuffer);