The findRecord: function() method is called in the findRecord method
Copy code The code is as follows: findRecord: function() {
var me = this,
index = me.find.apply(me, arguments);
return index !== -1 ? me.getAt(index) : null;
},
Enter the find method
Copy the code
The code is as follows: find: function(property, value, start, anyMatch, caseSensitive, exactMatch) {
var fn = this.createFilterFn(property, value, anyMatch, caseSensitive, exactMatch);
return fn ? this .data.findIndexBy(fn, null, start) : -1;
},
createFilterFn method
createFilterFn: function(property, value, anyMatch, caseSensitive, exactMatch) {
if (Ext. isEmpty(value)) {
return false;
}
value = this.data.createValueMatcher(value, anyMatch, caseSensitive, exactMatch);
return function(r) {
return value .test(r.data[property]);
};
},
findIndexBy : function(fn, scope, start){
var me = this,
keys = me. keys,
items = me.items,
i = start || 0,
len = items.length;
for (; i < len; i ) {
if (fn.call(scope || me, items[i], keys[i])) {
return i;
}
}
return -1;
},
Please note
value.test(r.data[property]); the BUG occurs here
The property I use here is the "ID" field.
Here It is to query the record with ID==1,
It is done through this loop
if (fn.call(scope || me, items[i], keys[i])) {
return i;
}
},
That is,
value.test(r.data[property]) is called every time
This judgment is made through regular expressions
You can test this situation
var b=value.test('15')//This is returned successfully.
I think everyone knows the reason.
When it is judged that ID=1, when an ID starting with 1 is encountered, a problem will be determined at this time.