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 为root
2.store 遍历二种方式
stroe.each(function(rec){
alert(rec.get('name'));//name 为fields 字段
or: alert(rec.data.name)//name 为fields 字段
})