Andrew Barker
Andrew Barker

Reputation: 73

Filter extjs Store by Exact Match

I have this code to filter through my store

onLicenseGridSelect: function(rowmodel, record, index, eOpts) {
    Ext.getStore('LicenseFeaturesStore').clearFilter();
    Ext.getStore('LicenseFeaturesStore').filter( 'license_id', record.data.license_id );
},

It works fine however I need to search an exact value, instead of anyMatch values, right now it just returns values that match in any way, how can I change this to search an exact value.

So say I have array values (3, 35, 36)

and I run filter for 3, it gives me all those results, I just would want 3

Upvotes: 0

Views: 1668

Answers (2)

Trương Long
Trương Long

Reputation: 120

This worked for me, hope it help!

var store = Ext.getStore('LicenseFeaturesStore');
var regEx = new RegExp('^' + 'ValueFilter' + '$');
store.filter('FilterColumn', regEx);

If you want filter exactly your value and one more empty row

 var regEx = new RegExp('^' + 'ValueFilter' + '$|^$');

Upvotes: 0

Andrew Barker
Andrew Barker

Reputation: 73

This worked like a charm

var store = Ext.getStore('LicenseFeaturesStore');
store.filter({
    property: 'license_id',
    exactMatch: true,
    value: record.data.license_id
});

Perfect, thanks

Upvotes: 2

Related Questions