Extjs Store findRecord query API

Source: Internet
Author: User

Extjs Store findRecord query API
Here are some examples to illustrate the simple use of the Store findRecord method. For example, if you have a userStore and want to find a user named Felix (the premise is that the user model must have a user field), the query is as follows: 1var user = userStore. findRecord ('firstname', 'Felix '); the result of code execution above returns a Model instance. Let's look at a simple example. The requirement is to get the employee ID of Felix. The query is as follows: getUserID: function (name) {var userStore = this. getUserStore (); var user = userStore. findRecord ('name', 'Felix '); return user. get ('id') ;}good. Here I want to explain some limitations of the findRecord method: I can only find the first matched record. If the current store is filtered, the matched record can only be searched in the data set to be filtered, instead of the original store. In addition, the findRecord method has several parameters. It must be noted that fieldName (required ): field namevalue to be used as the query condition (required): the value of the query, matching the fieldName startIndex (optional): from which the store The default value is 0 anyMatch (Optional). The default value is match starting from the first character, similar to 'a % 'in SQL. If it is set to True, it is full match, similar to '% a %' in SQL. The default value is falsecaseSensitive (Optional). If it is set to true, Case sensitivity is enabled. The default value is falseexactMacth (Optional). If it is set to True, exact query is performed, the default value is false (^ and $ characters added to the regex ). for the last parameter exactMacth, it is worth noting that if the data in a store is [[['000000', 'po'], ['000000', 'so'], ['1 ', 'si'], model is {fieldOid, fieldName }. in this case, you need to find the filedName value of the record whose fieldOid is 1 (the correct result is SI) var field = fieldStore. fi NdRecord ('fieldid', '1'); var fieldName = field. get ('fieldname'); we think it should be okay to get the SI value, but the result is PO, why? I found an article on the Internet http://www.bkjia.com/kf/201306/218487.html said this is a bug in EXTJS, I think it should not. Because the value query is done through a regular expression, when 1 is passed in as a value, the API uses an expression similar to SQL 'a % 'for query. Of course, 145 is found, therefore, the returned result is PO. Therefore, the following query is required to query the expected records accurately: var field = fieldStore. findRecord ('fieldid', '1', 0, false, false, true); var fieldName = field. get ('fieldname ');

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.