Ext. Data. Store load and display data

Source: Internet
Author: User

After the store is created, you must call the load () function to load data. After the load is successful, you can operate on the data in the store. The complete process of load () calling is as follows:Code.

Store. Load ({

Params: {start: 0, limit: 20 },

Callback: function (records, options, success ){

Ext. msg. Alert ('info', 'Load finished ');

},

Scope: store,

Add: True

});

-Params is an additional parameter sent during store loading.

-Callback is the callback function executed when the load is completed. It contains three parameters: the records parameter indicates the data obtained, and the options parameter indicates the parameter passed when the load () is executed, success indicates whether the load is successful.

-Scope is used to specify the scope of the callback function execution.

-When "add" is set to "true", the data obtained by load () is added to the end of the original store data. Otherwise, the data is cleared before being added to the store.

 

Generally, to initialize the data in the store, the load () function only needs to be executed once. If you use the Params parameter to specify the required parameter, and then run reload () to reload the data again, the store will automatically use the Params parameter content contained in the last load.

 

If some parameters need to be fixed, you can also use the baseparams parameter for execution. It is a JSON object and the data in it will be sent to the background for processing as parameters, as shown in the following code.

Store. baseparams. Start = 0;

Store. baseparams. Limit = 20;

 

After loading data for the store, you can use the FunctionFilterAndFilterbyFilter the data in the store and only display the qualified parts, as shown in the following code.

Filter (string field, string/Regexp value, [Boolean anymatch],
[Boolean casesensitive]): void

The usage of the filter () function is similar to that of find (), as shown in the following code.

Store. Filter ('name', 'boys ');

The corresponding filterby () is similar to findby (). You can also implement various complex judgments in custom functions, as shown in the following code.

Store. filterby (function (record ){

Return record. Get ('name') = 'girl '& record. Get ('sex') = 1;

});

To cancel filtering and display all data, you can callClearfilter ()Function, as shown in the following code.

Store. clearfilter ();

If you want to know whether a filter is set on the store, you can useIsfiltered ()Function.

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.