source: trunk/web/addons/job_monarch/lib/extjs/examples/grid-filtering/grid/filter/BooleanFilter.js @ 619

Last change on this file since 619 was 619, checked in by ramonb, 15 years ago

lib/:

  • added new AJAX dependancies: ExtJS, pChart, Lightbox2
File size: 1.6 KB
Line 
1/*
2 * Ext JS Library 2.2.1
3 * Copyright(c) 2006-2009, Ext JS, LLC.
4 * licensing@extjs.com
5 *
6 * http://extjs.com/license
7 */
8
9Ext.grid.filter.BooleanFilter = Ext.extend(Ext.grid.filter.Filter, {
10    /**
11     * @cfg {Boolean} defaultValue
12     * The default value of this filter (defaults to false)
13     */
14    defaultValue: false,
15    /**
16     * @cfg {String} yesText
17     * The text displayed for the "Yes" checkbox
18     */
19    yesText: 'Yes',
20    /**
21     * @cfg {String} noText
22     * The text displayed for the "No" checkbox
23     */
24    noText: 'No',
25
26        init: function(){
27            var gId = Ext.id();
28                        this.options = [
29                                new Ext.menu.CheckItem({text: this.yesText, group: gId, checked: this.defaultValue === true}),
30                                new Ext.menu.CheckItem({text: this.noText, group: gId, checked: this.defaultValue === false})
31            ];
32               
33                this.menu.add(this.options[0], this.options[1]);
34               
35                for(var i=0; i<this.options.length; i++) {
36                        this.options[i].on('click', this.fireUpdate, this);
37                        this.options[i].on('checkchange', this.fireUpdate, this);
38                }
39        },
40       
41        isActivatable: function() {
42                return true;
43        },
44       
45        fireUpdate: function() {               
46                this.fireEvent("update", this);                 
47                this.setActive(true);
48        },
49       
50        setValue: function(value) {
51                this.options[value ? 0 : 1].setChecked(true);
52        },
53       
54        getValue: function() {
55                return this.options[0].checked;
56        },
57       
58        serialize: function() {
59                var args = {type: 'boolean', value: this.getValue()};
60                this.fireEvent('serialize', args, this);
61                return args;
62        },
63       
64        validateRecord: function(record) {
65                return record.get(this.dataIndex) == this.getValue();
66        }
67});
Note: See TracBrowser for help on using the repository browser.