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.ListFilter"></div>/**
16 * @class Ext.ux.grid.filter.ListFilter
17 * @extends Ext.ux.grid.filter.Filter
18 * <p>List filters are able to be preloaded/backed by an Ext.data.Store to load
19 * their options the first time they are shown. ListFilter utilizes the
20 * {@link Ext.ux.menu.ListMenu} component.</p>
21 * <p>Although not shown here, this class accepts all configuration options
22 * for {@link Ext.ux.menu.ListMenu}.</p>
24 * <p><b><u>Example Usage:</u></b></p>
26 var filters = new Ext.ux.grid.GridFilters({
32 // options will be used as data to implicitly creates an ArrayStore
33 options: ['extra small', 'small', 'medium', 'large', 'extra large']
39 Ext.ux.grid.filter.ListFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
41 <div id="cfg-Ext.ux.grid.filter.ListFilter-options"></div>/**
42 * @cfg {Array} options
43 * <p><code>data</code> to be used to implicitly create a data store
44 * to back this list when the data source is <b>local</b>. If the
45 * data for the list is remote, use the <code>{@link #store}</code>
47 * <br><p>Each item within the provided array may be in one of the
48 * following formats:</p>
49 * <div class="mdetail-params"><ul>
63 labelField: 'name', // override default of 'text'
65 {id: 11, name:'extra small'},
66 {id: 18, name:'small'},
67 {id: 22, name:'medium'},
68 {id: 35, name:'large'},
69 {id: 44, name:'extra large'}
75 * options: ['extra small', 'small', 'medium', 'large', 'extra large']
79 <div id="cfg-Ext.ux.grid.filter.ListFilter-phpMode"></div>/**
80 * @cfg {Boolean} phpMode
81 * <p>Adjust the format of this filter. Defaults to false.</p>
82 * <br><p>When GridFilters <code>@cfg encode = false</code> (default):</p>
84 // phpMode == false (default):
85 filter[0][data][type] list
86 filter[0][data][value] value1
87 filter[0][data][value] value2
91 filter[0][data][type] list
92 filter[0][data][value] value1, value2
95 * When GridFilters <code>@cfg encode = true</code>:
97 // phpMode == false (default):
98 filter : [{"type":"list","value":["small","medium"],"field":"size"}]
101 filter : [{"type":"list","value":"small,medium","field":"size"}]
105 <div id="cfg-Ext.ux.grid.filter.ListFilter-store"></div>/**
106 * @cfg {Ext.data.Store} store
107 * The {@link Ext.data.Store} this list should use as its data source
108 * when the data source is <b>remote</b>. If the data for the list
109 * is local, use the <code>{@link #options}</code> config instead.
114 * Template method that is to initialize the filter and install required menu items.
115 * @param {Object} config
117 init : function (config) {
118 this.dt = new Ext.util.DelayedTask(this.fireUpdate, this);
120 // if a menu already existed, do clean up first
124 this.menu = new Ext.ux.menu.ListMenu(config);
125 this.menu.on('checkchange', this.onCheckChange, this);
130 * Template method that is to get and return the value of the filter.
131 * @return {String} The value of this filter
133 getValue : function () {
134 return this.menu.getSelected();
138 * Template method that is to set the value of the filter.
139 * @param {Object} value The value to set the filter
141 setValue : function (value) {
142 this.menu.setSelected(value);
143 this.fireEvent('update', this);
148 * Template method that is to return <tt>true</tt> if the filter
149 * has enough configuration information to be activated.
152 isActivatable : function () {
153 return this.getValue().length > 0;
158 * Template method that is to get and return serialized filter data for
159 * transmission to the server.
160 * @return {Object/Array} An object or collection of objects containing
161 * key value pairs representing the current configuration of the filter.
163 getSerialArgs : function () {
164 var args = {type: 'list', value: this.phpMode ? this.getValue().join(',') : this.getValue()};
169 onCheckChange : function(){
170 this.dt.delay(this.updateBuffer);
174 <div id="method-Ext.ux.grid.filter.ListFilter-validateRecord"></div>/**
175 * Template method that is to validate the provided Ext.data.Record
176 * against the filters configuration.
177 * @param {Ext.data.Record} record The record to validate
178 * @return {Boolean} true if the record is valid within the bounds
179 * of the filter, false otherwise.
181 validateRecord : function (record) {
182 return this.getValue().indexOf(record.get(this.dataIndex)) > -1;