1.store 加载异常处理与加载信息提示
var msgTip = ''; // 一定要定义在使用前,且定义为全局变量
//--------------------------------store---------------------------------------------------------------//
window.panelStore5 = Ext.create('Ext.data.Store', {
fields:[{name:'name'},{name:'preStatics',type:'int'},'mypercent'],
proxy: {
type: 'ajax',
url: extPath+'/center!getDetailByType.action?random='+new Date().getTime()+''+'&type=5',
reader: {
type: 'json',
root: 'humresData',
totalProperty: 'totalCount'
}
},
autoLoad: false,
sorters:[{
property:"name",
direction:"asc"
},{
property:"preStatics",
direction:"asc"
}],
listeners:{
beforeload:function(store,records,successful,operation,opts){
msgTip = Ext.MessageBox.show({
title:'提示',
width : 250,
msg:'页面统计信息刷新中,请稍后...',
buttons: Ext.Msg.OK
});
},
load:function(store,records,successful,operation,opts){
if(successful){
Ext.Msg.alert('提示','数据加载成功!');
msgTip.hide();
}else{
Ext.Msg.alert('提示','数据加载失败!');
msgTip.hide();
}
}
}
}); 服务器 返回数值 类似:{ success:true,humerdata:{name:'andy',password:123123} } //humerdata 为root2.store 遍历二种方式
stroe.each(function(rec){
alert(rec.get('name'));//name 为fields 字段
or: alert(rec.data.name)//name 为fields 字段
})
本文介绍如何在ExtJS中处理Store加载异常及加载提示信息,并演示两种遍历Store的方法。首先通过全局变量提示加载状态,其次实现Store加载成功与失败的不同提示,并展示服务器返回的数据结构。最后通过两种不同方式遍历Store,获取具体字段。
1037

被折叠的 条评论
为什么被折叠?



