2

I have a grid with lots of records in it. so I want to add filters in each column header to filter the required data easily. I have seen the example given in the sencha docs. But How to implement it in the Extjs 4.2 version. How to use UX classes in it? Is there any plugin available?

I am greatly thankful to you.

Please help me.

Anand

4 Answers 4

3

This is an example:

Ext.define('Webdesktop.view.admin.List', {
extend: 'Ext.grid.Panel',
alias: 'widget.admin_casoslist',
initComponent: function() {
    var me = this,
    filters = {
        ftype: 'filters',
        encode: false,
        local: true
    };

    Ext.apply(me, {
        title: 'gridTitle',
        store: List_CasSos_Store,

        filterable: true,
        features: [filters],
        closable: true, // fixme: need to set here, because has no effect in tabpanel defaults configuration
        autoScroll: true,
        columns: {
            items:[
            {
                text: 'header1',
                filter: {
                    type: 'string'
                },
                flex: 1,
                dataIndex: 'relation_patron_paraine'
            },{
                text:'header2',
                filter: {
                    type: 'list',
                    options: ['case4', 'case3', 'case2', 'case1']
                },
                hidden:true,
                flex: 1,
                dataIndex: 'etatsante'
            },{
                text:'header3',
                filter: {
                    type: 'numeric'
                },
                hidden:true,
                flex: 1,
                dataIndex: 'revenumnsuel'
            }
            ],
            defaults : {
                align: 'center'
            }
        }
    });
    me.callParent();
}

In the controller:

uses: [
   'Webdesktop.view.admin.List',
    ...
   'Ext.ux.grid.FiltersFeature'
    ]
6
  • 1
    You should require 'Ext.ux.grid.FiltersFeature'
    – Aminesrine
    Jun 13, 2013 at 14:36
  • How to include the 'Ext.ux.grid.FiltersFeature' in my app..? Jun 14, 2013 at 9:03
  • I have included the UX filter class in the application. How to add filters in the column definitions. I mean are they need to be manually specified or listed in Config options...? Jun 25, 2013 at 9:22
  • In every column you should specify the filter, like shown in the code above.
    – Aminesrine
    Jun 25, 2013 at 10:46
  • there are no options to add filters in architect, Do i need to override the code.? and Filter config..? and how to create path like this... Ext.Loader.setPath('Ext.ux', '../ux'); Jul 2, 2013 at 13:28
2

You need to add this to your grid configuration:

plugins: [{
  ptype: 'gridfilters'
}],

And then in each column:

filter: {type: 'string', dataIndex: 'passengerFullName'},

Note that the filter is depended on store whether it will be a remote filter or a local filter.

See here for more info: http://docs.sencha.com/extjs/6.0.2-classic/Ext.grid.filters.Filters.html

1

To use filter in header of grid you need to declare array of filter and then give scope to grid. Then write

this.filters = new Ext.ux.grid.GridFilters({
            filters:this.filter
        }) ;

Give a plugin for that

this.plugins = [this.filters];

Where you adding column write

gridEl.filter{
        type: 'list',
        dataIndex: "DATAINDEX",
        local : local,
        dataForFilter : data
    };
0

One solution it's to capture the "column click" column, get the param that you want to filter and in the function put this filter on the Grid Store.

Column Example

{
    header      : "email",
    dataIndex   : 'email',
    listeners : {
        click: {
            element: 'el', //bind to the underlying el property on the panel
            fn: function(){ 
                storeGrid.filter("email", /\.com$/); // email
                            storeGrid.sort('myField', 'ASC');
            }
        }
    }
},

Sencha Filter: filter store

Sencha Sort: sort store data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.