Index

Classes

Class

Methods

Class Banana.Controls.DataGridFilterManager


Extends Banana.Control.

Methods borrowed from class Banana.Control:
addControl, applyToChildren, bind, clear, createComponents, findControl, generateUniqueId, getClientId, getControls, getDomEventTypes, getFirstUiControl, getHtml, getId, getPage, getParent, getProxy, hasBind, invalidateDisplay, onPreInvalidateContents, onWindowResize, remove, render, setClientId, setId, setPage, setParent, triggerEvent, unbind, unload, updateDisplay

Defined in: DataGridFilterManager.js.

Class Detail
Banana.Controls.DataGridFilterManager()

Creates a Filter Manager for usage in a datagrid. It centralize filter functionality of a datagrid by keeping track of filter changes and history. It saves data from the filters in the url and cookie.

Filters should be added by calling setFilters([]);

Filters should have an interface that at least contains:

function getAllKey(): returns the key that should be used when "all" is selected

Filters can trigger the following events:

  • filterUrlChanged: triggered when url param of the filter is changed
  • filterDataChanged: triggered when the filter data is changed

Example

    var filterManager= new Banana.Controls.DataGridFilterManager();
    filterManager.setUrlPreFix(pageId); 

    //everytime a filter changes, we come here. this could be the place to reload/update
    //the data of the datagrid
    filterManager.bind('filtersChanged',this.getProxy(function(e,filterData)
    {      
            this.populateData(filterData);
    }));

    //assign some filters to the filterManager
    filterManager.setFilters([

                            new Banana.Controls.DataGridDropDownFilter()
                            .setFilterField('type')
                            .setAllTitle('All Program types')
                            .dataSetSourceBind('programtypes','programtypes'),  

                            new Banana.Controls.DataGridDropDownFilter()
                            .setFilterField('country')
                            .setAllTitle('All Series')
                            .dataSetSourceBind('programSeries','items'),  

                             new Banana.Controls.DataGridCheckboxFilter()
                            .setFilterField('archive')
                            .setTitle('Display archived items'),

                             new Banana.Controls.DataGridSearchFilter()
                             .setFilterField('search'),

                            this.pagerFilter = new Banana.Controls.DataGridPagerFilter()
                            .setFilterField('pageIndex')
                            .dataSetSourceBind('dataset','pageCount')
                            .dataSetBind('dataset','pageIndex')
                            ]);


    //this is an array of filter controls. Just add them somewhere on your site.
    //You can also add them in a DatagridControlPanel. It will automatically align them nicely. 
    var filters = filterManager.getFilters();
Method Detail
clearCache()

Clears the cache of the filter

{this} disableHistory()

When invoked we will not try to restore filter states based on history

Returns:
{this}
{Filter} getFilterById(filter)
Parameters:
{String} filter
id of the filter
Returns:
{Filter}
{object} getFilterData(ignoreCache, flat, ignoreNotVisible)

Gets the current filter data each data part contains an object with - filterField name of the filter field - data the actual data - dataChanged boolean true when the filter is changed by the user

Parameters:
{boolean} ignoreCache
when true we don't use the cache
{boolean} flat
when true we return key value array
{boolean} ignoreNotVisible
when true we don't include the invisble filters in the returned data
Returns:
{object} data of the filters
{Array} getFilters()
Returns:
{Array} of filters
{this} ignoreAutoVisible()

when called we do not auto adjust filter visibility. Normaly filters are hidden when no datasource is inside the filter.

Returns:
{this}
removeFilterValues(filter)

removes filter values from url and cookie

Parameters:
filter
{this} setFilters(filters)

Set filters for this filtermanager. Each filter should extend from Banana.Controls.BaseDataGridFilter The data inside the filter can be set manually on each filter. If it is not manualy set we try to fetch it from the history. That means that if a user already used the filter or url param name we set that value back into the filter. Handy when user comes back to a page he already visited. The fiters will be restored to the old state. This restore operation can be avoided by called

Parameters:
{Array} filters
the filters
Returns:
{this}
setFilterValue(filter, value)
Parameters:
{mixed} filter
Filter itself or an id
{String} value
{this} setKeepAllValueInUrl(bool)

Filters can contain a so called all value. This value is used in cases where the user wants to unselect the filter. Normally we don't show this value in the url. This method will make that value visible. Useful when you need to know if a user selected the all value after coming from another page.

Parameters:
{Boolean} bool
Returns:
{this}
{this} setUrlPreFix(pf)

a prefix to save before every url param (cookie included) we do this if we have 2 datagrids and dont want to let duplicated filter params interfer with each other.

Parameters:
{String} pf
Returns:
{this}
showBindedOnly()

when called we only show filters which are binded with data

Returns:
this;

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 05 2012 22:01:35 GMT+0100 (CET)