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.BooleanFilter"></div>/**
16 * @class Ext.ux.grid.filter.BooleanFilter
17 * @extends Ext.ux.grid.filter.Filter
18 * Boolean filters use unique radio group IDs (so you can have more than one!)
19 * <p><b><u>Example Usage:</u></b></p>
21 var filters = new Ext.ux.grid.GridFilters({
29 defaultValue: null, // leave unselected (false selected by default)
30 yesText: 'Yes', // default
31 noText: 'No' // default
36 Ext.ux.grid.filter.BooleanFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
37 <div id="cfg-Ext.ux.grid.filter.BooleanFilter-defaultValue"></div>/**
38 * @cfg {Boolean} defaultValue
39 * Set this to null if you do not want either option to be checked by default. Defaults to false.
42 <div id="cfg-Ext.ux.grid.filter.BooleanFilter-yesText"></div>/**
43 * @cfg {String} yesText
47 <div id="cfg-Ext.ux.grid.filter.BooleanFilter-noText"></div>/**
48 * @cfg {String} noText
55 * Template method that is to initialize the filter and install required menu items.
57 init : function (config) {
60 new Ext.menu.CheckItem({text: this.yesText, group: gId, checked: this.defaultValue === true}),
61 new Ext.menu.CheckItem({text: this.noText, group: gId, checked: this.defaultValue === false})];
63 this.menu.add(this.options[0], this.options[1]);
65 for(var i=0; i<this.options.length; i++){
66 this.options[i].on('click', this.fireUpdate, this);
67 this.options[i].on('checkchange', this.fireUpdate, this);
73 * Template method that is to get and return the value of the filter.
74 * @return {String} The value of this filter
76 getValue : function () {
77 return this.options[0].checked;
82 * Template method that is to set the value of the filter.
83 * @param {Object} value The value to set the filter
85 setValue : function (value) {
86 this.options[value ? 0 : 1].setChecked(true);
91 * Template method that is to get and return serialized filter data for
92 * transmission to the server.
93 * @return {Object/Array} An object or collection of objects containing
94 * key value pairs representing the current configuration of the filter.
96 getSerialArgs : function () {
97 var args = {type: 'boolean', value: this.getValue()};
101 <div id="method-Ext.ux.grid.filter.BooleanFilter-validateRecord"></div>/**
102 * Template method that is to validate the provided Ext.data.Record
103 * against the filters configuration.
104 * @param {Ext.data.Record} record The record to validate
105 * @return {Boolean} true if the record is valid within the bounds
106 * of the filter, false otherwise.
108 validateRecord : function (record) {
109 return record.get(this.dataIndex) == this.getValue();