source: trunk/web/addons/job_monarch/lib/extjs/examples/grid-filtering/grid/filter/Filter.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: 3.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.ns("Ext.grid.filter");
10Ext.grid.filter.Filter = function(config){
11        Ext.apply(this, config);
12               
13        this.events = {
14                /**
15                 * @event activate
16                 * Fires when a inactive filter becomes active
17                 * @param {Ext.ux.grid.filter.Filter} this
18                 */
19                'activate': true,
20                /**
21                 * @event deactivate
22                 * Fires when a active filter becomes inactive
23                 * @param {Ext.ux.grid.filter.Filter} this
24                 */
25                'deactivate': true,
26                /**
27                 * @event update
28                 * Fires when a filter configuration has changed
29                 * @param {Ext.ux.grid.filter.Filter} this
30                 */
31                'update': true,
32                /**
33                 * @event serialize
34                 * Fires after the serialization process. Use this to apply additional parameters to the serialized data.
35                 * @param {Array/Object} data A map or collection of maps representing the current filter configuration.
36                 * @param {Ext.ux.grid.filter.Filter} filter The filter being serialized.
37                 **/
38                'serialize': true
39        };
40        Ext.grid.filter.Filter.superclass.constructor.call(this);
41       
42        this.menu = new Ext.menu.Menu();
43        this.init();
44       
45        if(config && config.value) {
46                this.setValue(config.value);
47                this.setActive(config.active !== false, true);
48                delete config.value;
49        }
50};
51Ext.extend(Ext.grid.filter.Filter, Ext.util.Observable, {
52        /**
53         * @cfg {Boolean} active
54         * Indicates the default status of the filter (defaults to false).
55         */
56    /**
57     * True if this filter is active. Read-only.
58     * @type Boolean
59     * @property
60     */
61        active: false,
62        /**
63         * @cfg {String} dataIndex
64         * The {@link Ext.data.Store} data index of the field this filter represents. The dataIndex does not actually
65         * have to exist in the store.
66         */
67        dataIndex: null,
68        /**
69         * The filter configuration menu that will be installed into the filter submenu of a column menu.
70         * @type Ext.menu.Menu
71         * @property
72         */
73        menu: null,
74       
75        /**
76         * Initialize the filter and install required menu items.
77         */
78        init: Ext.emptyFn,
79       
80        fireUpdate: function() {
81                this.value = this.item.getValue();
82               
83                if(this.active) {
84                        this.fireEvent("update", this);
85    }
86                this.setActive(this.value.length > 0);
87        },
88       
89        /**
90         * Returns true if the filter has enough configuration information to be activated.
91         * @return {Boolean}
92         */
93        isActivatable: function() {
94                return true;
95        },
96       
97        /**
98         * Sets the status of the filter and fires that appropriate events.
99         * @param {Boolean} active        The new filter state.
100         * @param {Boolean} suppressEvent True to prevent events from being fired.
101         */
102        setActive: function(active, suppressEvent) {
103                if(this.active != active) {
104                        this.active = active;
105                        if(suppressEvent !== true) {
106                                this.fireEvent(active ? 'activate' : 'deactivate', this);
107      }
108                }
109        },
110       
111        /**
112         * Get the value of the filter
113         * @return {Object} The 'serialized' form of this filter
114         */
115        getValue: Ext.emptyFn,
116       
117        /**
118         * Set the value of the filter.
119         * @param {Object} data The value of the filter
120         */     
121        setValue: Ext.emptyFn,
122       
123        /**
124         * Serialize the filter data for transmission to the server.
125         * @return {Object/Array} An object or collection of objects containing key value pairs representing
126         *      the current configuration of the filter.
127         */
128        serialize: Ext.emptyFn,
129       
130        /**
131         * Validates the provided Ext.data.Record against the filters configuration.
132         * @param {Ext.data.Record} record The record to validate
133         * @return {Boolean} True if the record is valid with in the bounds of the filter, false otherwise.
134         */
135         validateRecord: function(){return true;}
136});
Note: See TracBrowser for help on using the repository browser.