开发者

How to apply exact match in Grid Filter feature using Extjs4?

I am using Extjs4 and I want to apply exactMatch on grid filtering. I am using the newly introduced Grid Filtering feature.I have tried to use exactMatch but it does not work. Here is my sample code:

Ext.define('MyModel', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'ID', type: 'string'},
            {name: 'Title', type: 'string'}
        ]
    });

var store = Ext.create('Ext.data.Store', {         
        model: 'MyModel',
        proxy: {
            type: 'ajax',                       
            url: 'myurl',                       
            reader: {
                type: 'json'                  
            }
        },
        sor开发者_C百科ters: [{
            property: 'ID',
            direction:'DESC'
        }],
        autoLoad:true            
    });

var filters = {
        ftype: 'filters',               
        encode: true, 
        local: true,   
        filters: [{
            type: 'numeric',
            dataIndex: 'ID',
            disabled: true
        },{
            type: 'string',
            dataIndex: 'Title',
            exactMatch:true
        }]
    };

var grid = Ext.create('Ext.grid.Panel', {
        store: store,
        columns: [{
            header: 'ID',
            dataIndex: 'ID',
            width: 20
        },{
            header: 'List Title',
            dataIndex: 'Title',
            flex:1
        }],
        renderTo: 'editor-grid',
        width: 700,
        height: 400,
        frame: true,                      
        features: [filters]
    });

Thanks..


It looks like for ExtJS V4.0, you don't have to configure seperate filter options for the grid as they are already included. You can just call the method on the store to filter after the data has been loaded like so:

store.filter("Title", "Bob");

or if you want to do multiple filters like so:

store.filter([
    {property: "email", value: "Bob"},
    {filterFn: function(item) { return item.get("ID") > 10; }}
]);


The grid's features property can only contain classes that have been extended from the Feature class.

See the Grouping Feature:

Ext.define('Ext.grid.feature.Grouping', {
    extend: 'Ext.grid.feature.Feature',
    alias: 'feature.grouping'
    // More properties and functions...
}

Grouping Feature Usage:

var groupingFeature = Ext.create('Ext.grid.feature.Grouping', {
    groupHeaderTpl: 'Group: {name} ({rows.length})', //print the number of items in the group
    startCollapsed: true // start all groups collapsed
});

var grid = Ext.create('Ext.grid.Panel', {
          features:[groupingFeature]
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜