DEMO code of the store findRecord BUG in EXTjs4.0

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.