Extjs4 operations on Store (loading/callback/adding) _ extjs

Source: Internet
Author: User
This article describes in detail the loading and callback problems and adds records that meet certain conditions from one store to another. If you are interested, please refer to them and hope to help you. 1. Question about loading and callback
The storage of ExtJs is usually delayed during loading. At this time, the Grid will appear blank first, and data will only appear after loading is complete. Therefore, we need to add a prompt message for it!
However, Store does not have the waitMsg attribute.

Solution:
1. Add a listener to store and listen to beforeload events. A prompt box is displayed before loading. After loading, the prompt box is closed.
2. callback is the load callback function, which is executed after the load is complete. Therefore, it is used to close the prompt box;
3. Be sure to add the callback function to the store reload method. The prompt box has been closed.
The main example code is as follows:

The Code is as follows:


VarmsgTip; // must be defined as a global variable before use.
Var reportStore = new Ext. data. Store ({
Proxy: reportProxy,
Reader: reportReader,
Listeners :{
Beforeload: function (){
MsgTip = Ext. MessageBox. show ({
Title: 'hup ',
Width: 250,
Msg: 'page report statistics are refreshing. Please wait ......'
});
}
}
});
ReportStore. load ({
Callback: function (records, options, success ){
MsgTip. hide (); // The loading is complete. Close the prompt box.
}
});
Note: If you call reload to refresh the page, add the callback function to reload the page to close the prompt box.
ReportStore. reload ({
Callback: function (records, options, success ){
MsgTip. hide (); // The loading is complete. Close the prompt box.
}
});
-------- Other parameters ------
Store. load ({
Params: {start: 0, limit: 20}, // Parameter
// Callback is the callback function executed when the load is complete. It contains three parameters: the records parameter indicates the data obtained,
// Options indicates the parameter passed when load () is executed, and success indicates whether the load is successful.
Callback: function (records, options, success ){
Ext. Msg. alert ('info', 'Load finished ');
},
Scope: store, // Scope is used to specify the scope during callback function execution.
Add: false // when Add is true, the data obtained by load () is added to the end of the original store data,
// Otherwise, the previous data is cleared before the obtained data is added to the store.
  
});


2. Add a qualified record from one store to another

The Code is as follows:


Var MyDocnumStore_Load = function (store ){
// Var index = 0;
Store. each (function (record ){
If (record. data. PlanCarNo! = '') {// Replace column_name with your column name, And '1' with your value
If (record. data. Docnum! = _ Rec. get ('docnum ')){
Var _ TmpStr = record. data. UseDate + '----->' + record. data. PlanCarNo;
MyDocnumStore. add ({
'Updocnum': record. data. Docnum
, 'Docnumdesc': _ TmpStr
, 'Usedate': record. data. UseDate
, 'Plancarno': record. data. PlanCarNo
});
}
}
})
MyDocnumStore. sort ('usedate', 'asc ');
};
MyDocnumStore_Load (mystore); // load the carpool list;

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.