Observable GridFilters
Package: | Ext.ux.grid |
Defined In: | GridFilters.js |
Class: | GridFilters |
Extends: | Observable |
GridFilter is a plugin (ptype='gridfilters'
) for grids that
allow for a slightly more robust representation of filtering than what is
provided by the default store.
Filtering is adjusted by the user using the grid's column header menu (this menu can be disabled through configuration). Through this menu users can configure, enable, and disable filters for each column.
Features:
stateId
in the Grid configuration.
beforestaterestore
and beforestatesave
events in order to be stateful.
filters
property is added to the grid pointing to
this plugin.filterupdate
event is added to the grid and is
fired upon onStateChange completion.Example usage:
var store = new Ext.data.GroupingStore({
...
});
var filters = new Ext.ux.grid.GridFilters({
autoReload: false, //don't reload automatically
local: true, //only filter locally
// filters may be configured through the plugin,
// or in the column definition within the column model configuration
filters: [{
type: 'numeric',
dataIndex: 'id'
}, {
type: 'string',
dataIndex: 'name'
}, {
type: 'numeric',
dataIndex: 'price'
}, {
type: 'date',
dataIndex: 'dateAdded'
}, {
type: 'list',
dataIndex: 'size',
options: ['extra small', 'small', 'medium', 'large', 'extra large'],
phpMode: true
}, {
type: 'boolean',
dataIndex: 'visible'
}]
});
var cm = new Ext.grid.ColumnModel([{
...
}]);
var grid = new Ext.grid.GridPanel({
ds: store,
cm: cm,
view: new Ext.grid.GroupingView(),
plugins: [filters],
height: 400,
width: 700,
bbar: new Ext.PagingToolbar({
store: store,
pageSize: 15,
plugins: [filters] //reset page to page 1 if filters change
})
});
store.load({params: {start: 0, limit: 15}});
// a filters property is added to the grid
grid.filters
Config Options | Defined By | |
---|---|---|
autoReload : Boolean Defaults to true, reloading the datasource when a filter change happens.
Set this to false to prevent the datastore ... Defaults to true, reloading the datasource when a filter change happens.
Set this to false to prevent the datastore from being reloaded if there
are changes to the filters. See updateBuffer . | GridFilters | |
encode : Boolean Specify true for buildQuery to use Ext.util.JSON.encode to
encode the filter query parameter sent with a remote requ... Specify true for buildQuery to use Ext.util.JSON.encode to
encode the filter query parameter sent with a remote request.
Defaults to false. | GridFilters | |
filterCls : String The css class to be applied to column headers with active filters.
Defaults to 'ux-filterd-column'. | GridFilters | |
filters : Array An Array of filters config objects. Refer to each filter type class for
configuration details specific to each filte... An Array of filters config objects. Refer to each filter type class for
configuration details specific to each filter type. Filters for Strings,
Numeric Ranges, Date Ranges, Lists, and Boolean are the standard filters
available. | GridFilters | |
listeners : Object A config object containing one or more event handlers to be added to this
object during initialization. This should ... A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the addListener example for attaching multiple handlers at once. DOM events from ExtJs Components While some ExtJs Component classes export selected DOM events (e.g. "click", "mouseover" etc), this
is usually only done when extra value can be added. For example the DataView's
| Observable | |
local : Boolean true to use Ext.data.Store filter functions (local filtering)
instead of the default (false) server side filtering. | GridFilters | |
menuFilterText : String defaults to 'Filters'. | GridFilters | |
paramPrefix : String The url parameter prefix for the filters.
Defaults to 'filter'. | GridFilters | |
showMenu : Boolean Defaults to true, including a filter submenu in the default header menu. | GridFilters | |
stateId : String Name of the value to be used to store state information. | GridFilters | |
updateBuffer : Integer Number of milliseconds to defer store updates since the last filter change. | GridFilters |
Method | Defined By | |
---|---|---|
addEvents( Object|String o , string Optional. )
:
voidAdds the specified events to the list of events which this Observable may fire. Adds the specified events to the list of events which this Observable may fire. Parameters:
| Observable | |
addFilter( Object/Ext.ux.grid.filter.Filter config )
:
Ext.ux.grid.filter.FilterAdds a filter to the collection and observes it for state change. Adds a filter to the collection and observes it for state change. Parameters:
| GridFilters | |
addFilters( Array/Ext.grid.ColumnModel filters )
:
voidAdds filters to the collection. Adds filters to the collection. Parameters:
| GridFilters | |
addListener( String eventName , Function handler , [Object scope ], [Object options ] )
:
voidAppends an event handler to this object. Appends an event handler to this object. Parameters:
| Observable | |
bindStore( Store store )
:
voidChanges the data store bound to this view and refreshes it. Changes the data store bound to this view and refreshes it. Parameters:
| GridFilters | |
buildQuery( Array filters )
:
ObjectFunction to take the active filters data and build it into a query.
The format of the query depends on the encode
c... Function to take the active filters data and build it into a query.
The format of the query depends on the encode
configuration:
Parameters:
| GridFilters | |
cleanParams( Object p )
:
voidRemoves filter related query parameters from the provided object. Removes filter related query parameters from the provided object. Parameters:
| GridFilters | |
clearFilters()
:
void Turns all filters off. This does not clear the configuration information
(see removeAll). Turns all filters off. This does not clear the configuration information
(see removeAll). Parameters:
| GridFilters | |
enableBubble( Object events )
:
voidEnables events fired by this Observable to bubble up an owner hierarchy by calling
this.getBubbleTarget() if present... Enables events fired by this Observable to bubble up an owner hierarchy by calling
This is commonly used by Ext.Components to bubble events to owner Containers. See Ext.Component.getBubbleTarget. The default implementation in Ext.Component returns the Component's immediate owner. But if a known target is required, this can be overridden to access the required target more quickly. Example:
Parameters:
| Observable | |
fireEvent( String eventName , Object... args )
:
BooleanFires the specified event with the passed parameters (minus the event name).
An event may be set to bubble up an Obse... Fires the specified event with the passed parameters (minus the event name). An event may be set to bubble up an Observable parent hierarchy (See Ext.Component.getBubbleTarget) by calling enableBubble. Parameters:
| Observable | |
getFilter( String dataIndex )
:
Ext.ux.grid.filter.FilterReturns a filter for the given dataIndex, if one exists. Returns a filter for the given dataIndex, if one exists. Parameters:
| GridFilters | |
getFilterClass( String type )
:
ClassFunction for locating filter classes, overwrite this with your favorite
loader to provide dynamic filter loading. Function for locating filter classes, overwrite this with your favorite
loader to provide dynamic filter loading. Parameters:
| GridFilters | |
getFilterData()
:
Array Returns an Array of the currently active filters. Returns an Array of the currently active filters. Parameters:
| GridFilters | |
hasListener( String eventName )
:
BooleanChecks to see if this object has any listeners for a specified event Checks to see if this object has any listeners for a specified event Parameters:
| Observable | |
on( String eventName , Function handler , [Object scope ], [Object options ] )
:
voidAppends an event handler to this object (shorthand for addListener.) Appends an event handler to this object (shorthand for addListener.) Parameters:
| Observable | |
purgeListeners()
:
void Removes all listeners for this object Removes all listeners for this object Parameters:
| Observable | |
relayEvents( Object o , Array events )
:
voidRelays selected events from the specified Observable as if the events were fired by this. Relays selected events from the specified Observable as if the events were fired by this. Parameters:
| Observable | |
removeAll()
:
void Remove all filters, permanently destroying them. Remove all filters, permanently destroying them. Parameters:
| GridFilters | |
removeListener( String eventName , Function handler , [Object scope ] )
:
voidRemoves an event handler. Removes an event handler. Parameters:
| Observable | |
resumeEvents()
:
void Resume firing events. (see suspendEvents)
If events were suspended using the queueSuspended parameter, then all
event... Resume firing events. (see suspendEvents)
If events were suspended using the queueSuspended parameter, then all
events fired during event suspension will be sent to any listeners now. Parameters:
| Observable | |
saveState( Object grid , Object state )
:
BooleanSaves the state of all active filters Saves the state of all active filters Parameters:
| GridFilters | |
suspendEvents( Boolean queueSuspended )
:
voidSuspend the firing of all events. (see resumeEvents) Suspend the firing of all events. (see resumeEvents) Parameters:
| Observable | |
un( String eventName , Function handler , [Object scope ] )
:
voidRemoves an event handler (shorthand for removeListener.) Removes an event handler (shorthand for removeListener.) Parameters:
| Observable | |
updateColumnHeadings()
:
void Update the styles for the header row based on the active filters Update the styles for the header row based on the active filters Parameters:
| GridFilters |