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.