3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js"><div id="cls-Ext.ux.grid.filter.ListFilter"></div>/**
\r
9 * @class Ext.ux.grid.filter.ListFilter
\r
10 * @extends Ext.ux.grid.filter.Filter
\r
11 * <p>List filters are able to be preloaded/backed by an Ext.data.Store to load
\r
12 * their options the first time they are shown. ListFilter utilizes the
\r
13 * {@link Ext.ux.menu.ListMenu} component.</p>
\r
14 * <p>Although not shown here, this class accepts all configuration options
\r
15 * for {@link Ext.ux.menu.ListMenu}.</p>
\r
17 * <p><b><u>Example Usage:</u></b></p>
\r
19 var filters = new Ext.ux.grid.GridFilters({
\r
25 // options will be used as data to implicitly creates an ArrayStore
\r
26 options: ['extra small', 'small', 'medium', 'large', 'extra large']
\r
32 Ext.ux.grid.filter.ListFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
\r
34 <div id="cfg-Ext.ux.grid.filter.ListFilter-options"></div>/**
\r
35 * @cfg {Array} options
\r
36 * <p><code>data</code> to be used to implicitly create a data store
\r
37 * to back this list when the data source is <b>local</b>. If the
\r
38 * data for the list is remote, use the <code>{@link #store}</code>
\r
39 * config instead.</p>
\r
40 * <br><p>Each item within the provided array may be in one of the
\r
41 * following formats:</p>
\r
42 * <div class="mdetail-params"><ul>
\r
43 * <li><b>Array</b> :
\r
46 [11, 'extra small'],
\r
54 * <li><b>Object</b> :
\r
56 labelField: 'name', // override default of 'text'
\r
58 {id: 11, name:'extra small'},
\r
59 {id: 18, name:'small'},
\r
60 {id: 22, name:'medium'},
\r
61 {id: 35, name:'large'},
\r
62 {id: 44, name:'extra large'}
\r
66 * <li><b>String</b> :
\r
68 * options: ['extra small', 'small', 'medium', 'large', 'extra large']
\r
72 <div id="cfg-Ext.ux.grid.filter.ListFilter-phpMode"></div>/**
\r
73 * @cfg {Boolean} phpMode
\r
74 * <p>Adjust the format of this filter. Defaults to false.</p>
\r
75 * <br><p>When GridFilters <code>@cfg encode = false</code> (default):</p>
\r
77 // phpMode == false (default):
\r
78 filter[0][data][type] list
\r
79 filter[0][data][value] value1
\r
80 filter[0][data][value] value2
\r
81 filter[0][field] prod
\r
84 filter[0][data][type] list
\r
85 filter[0][data][value] value1, value2
\r
86 filter[0][field] prod
\r
88 * When GridFilters <code>@cfg encode = true</code>:
\r
90 // phpMode == false (default):
\r
91 filter : [{"type":"list","value":["small","medium"],"field":"size"}]
\r
94 filter : [{"type":"list","value":"small,medium","field":"size"}]
\r
98 <div id="cfg-Ext.ux.grid.filter.ListFilter-store"></div>/**
\r
99 * @cfg {Ext.data.Store} store
\r
100 * The {@link Ext.data.Store} this list should use as its data source
\r
101 * when the data source is <b>remote</b>. If the data for the list
\r
102 * is local, use the <code>{@link #options}</code> config instead.
\r
107 * Template method that is to initialize the filter and install required menu items.
\r
108 * @param {Object} config
\r
110 init : function (config) {
\r
111 this.dt = new Ext.util.DelayedTask(this.fireUpdate, this);
\r
113 // if a menu already existed, do clean up first
\r
115 this.menu.destroy();
\r
117 this.menu = new Ext.ux.menu.ListMenu(config);
\r
118 this.menu.on('checkchange', this.onCheckChange, this);
\r
123 * Template method that is to get and return the value of the filter.
\r
124 * @return {String} The value of this filter
\r
126 getValue : function () {
\r
127 return this.menu.getSelected();
\r
131 * Template method that is to set the value of the filter.
\r
132 * @param {Object} value The value to set the filter
\r
134 setValue : function (value) {
\r
135 this.menu.setSelected(value);
\r
136 this.fireEvent('update', this);
\r
141 * Template method that is to return <tt>true</tt> if the filter
\r
142 * has enough configuration information to be activated.
\r
143 * @return {Boolean}
\r
145 isActivatable : function () {
\r
146 return this.getValue().length > 0;
\r
151 * Template method that is to get and return serialized filter data for
\r
152 * transmission to the server.
\r
153 * @return {Object/Array} An object or collection of objects containing
\r
154 * key value pairs representing the current configuration of the filter.
\r
156 getSerialArgs : function () {
\r
157 var args = {type: 'list', value: this.phpMode ? this.getValue().join(',') : this.getValue()};
\r
162 onCheckChange : function(){
\r
163 this.dt.delay(this.updateBuffer);
\r
167 <div id="method-Ext.ux.grid.filter.ListFilter-validateRecord"></div>/**
\r
168 * Template method that is to validate the provided Ext.data.Record
\r
169 * against the filters configuration.
\r
170 * @param {Ext.data.Record} record The record to validate
\r
171 * @return {Boolean} true if the record is valid within the bounds
\r
172 * of the filter, false otherwise.
\r
174 validateRecord : function (record) {
\r
175 return this.getValue().indexOf(record.get(this.dataIndex)) > -1;
\r