Home > Web Front-end > JS Tutorial > Extjs4 Some operations on Store (loading/callback/adding)_extjs

Extjs4 Some operations on Store (loading/callback/adding)_extjs

WBOY
Release: 2016-05-16 17:36:14
Original
1388 people have browsed it
1. Issues about loading and callbacks
ExtJs Store is usually delayed when loading. At this time, the Grid will appear blank first, and the data will not appear until the loading is completed; therefore, we Need to add a prompt message to it!
But Store does not have waitMsg attribute.

Solution:
1. Add a listener to the store, listen for the beforeload event, pop up a prompt box before loading, and close the prompt box after the loading is completed
2. The callback is load The callback function is executed after the loading is completed, so closing the prompt box is completed by it;
3. Be sure to add a callback function to the reload method of the store. The prompt box has been closed
The main code of the example is as follows:
Copy code The code is as follows:

varmsgTip; // Must be defined before use and defined as global Variable
var reportStore=new Ext.data.Store({
proxy:reportProxy,
reader:reportReader,
listeners:{
beforeload:function(){
msgTip = Ext .MessageBox.show({
title: 'Prompt',
width : 250,
msg: 'Page report statistics are being refreshed, please wait...'
}) ;
}
}
});
reportStore.load({
callback: function(records, options, success){
msgTip.hide(); // Loading completed , close the prompt box
}
});
Note: If reload is called to refresh the page, reload must also add a callback function to close the prompt box
reportStore.reload({
callback : function(records, options, success){
msgTip.hide(); // Loading completed, close the prompt box
}
});
--------The following is Other parameters ------
store.load({
params:{start:0,limit:20}, //Parameters
// callback is the callback function executed when loading is completed. It Contains 3 parameters: the records parameter represents the obtained data,
// options represents the parameters passed when executing load(), and success represents whether the loading is successful.
callback: function(records, options, success){
Ext.Msg.alert('info', 'Loading completed');
},
scope: store, //Scope is used to specify the scope when the callback function is executed
add: false // When Add is true, the data obtained by load() will be added at the end of the original store data.
// Otherwise, the previous data will be cleared first, and then the obtained data will be added to the store
 
} );

2. Add records that meet certain conditions from one store to another store
Copy code 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, '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 carpooling list;
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template