Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store filter in sencha touch

I have store having structure :

Ext.create('Ext.data.Store', {
    fields: [
        'title'
    ],
    data: [{
        title: 'ABC'
    }, {
        title: 'ABC2'
    }, {
        title: 'ABC3'
    }, {
        title: 'ABC4'
    }, {
        title: 'ABC5'
    }, {
        title: 'ABC6'
    }]
});

So when I load this store List get populated with all 6 records.

I just wanted to Filter this store on button click I just wanted to get some selected record out of this 6 record Can It be possible.

Provide me Some Idea or Working code.

like image 420
Vinayak Avatar asked Sep 04 '13 05:09

Vinayak


1 Answers

To filter the store based on title

Ext.getStore('storeId').filter("title", "ABC3");

To clear filter

 Ext.getStore('storeId').clearFilter();

See store filter doc

Update

Ext.getStore('storeId').filterBy(function(record){
   var title = record.get('title');
   if(title == "ABC" || title == "ABC1" || title == "ABC2")
      return record;
});
like image 200
Viswa Avatar answered Oct 28 '22 06:10

Viswa