How could we find exact match of value in store
i tried below but its not working properly
Code:store.find('name','demo')
Printable View
How could we find exact match of value in store
i tried below but its not working properly
Code:store.find('name','demo')
Its solved now
Code:var val="^demo$";
var newval=new RegExp(val);
store.find('name',newval);
Can't find the right if there exists special characters ( , ) , ?...
Solution :
Code:Ext.override(Ext.data.Store,{
/**
* Finds the index of the first matching record in this store by a specific property/value.
* @param {String} property A property on your objects
* @param {String/RegExp} value The value to match against
* @param {Number} startIndex (optional) The index to start searching at
* @return {Number} The matched index or -1
*/
findExact: function(property, value, start){
return this.data.findIndexBy(function(rec){
return rec.get(property) === value;
}, this, start);
}
});
example: store.findExact("name","Finds the index (1)");