The findRecord: function () method is called in the findRecord method.
Copy codeThe 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 codeThe 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;
},
Note:
Value. test (r. data [property]); where a BUG exists
Here, property is used as the "ID" field.
Here we query the record with ID = 1,
It uses this loop.
Copy codeThe Code is as follows:
For (; I <len; I ++ ){
If (fn. call (scope | me, items [I], keys [I]) {
Return I;
}
},
That is, every call
Value. test (r. data [property])
This judgment is done through a regular expression,
You can test this situation.
Copy codeThe Code is as follows:
Var value = new RegExp ('1 ');
Var B = value. test ('15') // The response is successful.
I think everyone knows why,
When ID = 1 is determined and an ID starting with 1 is met, the problem is determined.