ExtJS 3.4 Ext.data.Store.find Bug

Let me start by saying I love ExtJS. It is such a great framework and more commercial grade than JQuery. However, today I found a bug with the find function on an Ext.data.Store.

fieldName, value, [startIndex], [anyMatch], [caseSensitive] ) 

Given a field name and a value it should return the first matching record. However I noticed by default it doesn’t search for an exact match but rather will return a record found if the value is a sub-string in the record’s field name. I noticed you can optionally pass a parameter called anyMatch that should be able to disable this default functionality. According to the documentation it states the following about anyMatch:

True to match any part of the string, not just the beginning”

However all my attempts to disable this functionality failed. Looking at the framework’s source it looks like there is an undocumented function called findExact that should be called when the parameter anyMatch is false.

As a workaround you could either call this function:

var index = myStore.findExact("propertyName", "valueToFind");

or use the documented function findBy like so:

var index = myStore.findBy(function (r, id) {
if (record.get("layername") == r.get("layername")) {
return true;
return false;

In either case if index is -1 no records were found.

I hope this will save someone some wasted time : ).