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.BooleanFilter"></div>/**
\r
9 * @class Ext.ux.grid.filter.BooleanFilter
\r
10 * @extends Ext.ux.grid.filter.Filter
\r
11 * Boolean filters use unique radio group IDs (so you can have more than one!)
\r
12 * <p><b><u>Example Usage:</u></b></p>
\r
14 var filters = new Ext.ux.grid.GridFilters({
\r
19 dataIndex: 'visible'
\r
22 defaultValue: null, // leave unselected (false selected by default)
\r
23 yesText: 'Yes', // default
\r
24 noText: 'No' // default
\r
29 Ext.ux.grid.filter.BooleanFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
\r
30 <div id="cfg-Ext.ux.grid.filter.BooleanFilter-defaultValue"></div>/**
\r
31 * @cfg {Boolean} defaultValue
\r
32 * Set this to null if you do not want either option to be checked by default. Defaults to false.
\r
34 defaultValue : false,
\r
35 <div id="cfg-Ext.ux.grid.filter.BooleanFilter-yesText"></div>/**
\r
36 * @cfg {String} yesText
\r
37 * Defaults to 'Yes'.
\r
40 <div id="cfg-Ext.ux.grid.filter.BooleanFilter-noText"></div>/**
\r
41 * @cfg {String} noText
\r
48 * Template method that is to initialize the filter and install required menu items.
\r
50 init : function (config) {
\r
53 new Ext.menu.CheckItem({text: this.yesText, group: gId, checked: this.defaultValue === true}),
\r
54 new Ext.menu.CheckItem({text: this.noText, group: gId, checked: this.defaultValue === false})];
\r
56 this.menu.add(this.options[0], this.options[1]);
\r
58 for(var i=0; i<this.options.length; i++){
\r
59 this.options[i].on('click', this.fireUpdate, this);
\r
60 this.options[i].on('checkchange', this.fireUpdate, this);
\r
66 * Template method that is to get and return the value of the filter.
\r
67 * @return {String} The value of this filter
\r
69 getValue : function () {
\r
70 return this.options[0].checked;
\r
75 * Template method that is to set the value of the filter.
\r
76 * @param {Object} value The value to set the filter
\r
78 setValue : function (value) {
\r
79 this.options[value ? 0 : 1].setChecked(true);
\r
84 * Template method that is to get and return serialized filter data for
\r
85 * transmission to the server.
\r
86 * @return {Object/Array} An object or collection of objects containing
\r
87 * key value pairs representing the current configuration of the filter.
\r
89 getSerialArgs : function () {
\r
90 var args = {type: 'boolean', value: this.getValue()};
\r
94 <div id="method-Ext.ux.grid.filter.BooleanFilter-validateRecord"></div>/**
\r
95 * Template method that is to validate the provided Ext.data.Record
\r
96 * against the filters configuration.
\r
97 * @param {Ext.data.Record} record The record to validate
\r
98 * @return {Boolean} true if the record is valid within the bounds
\r
99 * of the filter, false otherwise.
\r
101 validateRecord : function (record) {
\r
102 return record.get(this.dataIndex) == this.getValue();
\r