store 加载异常处理与加载信息提示

  1.      var msgTip = '';   // 一定要定义在使用前,且定义为全局变量  
  2. /--------------------------------store---------------------------------------------------------------//  
  3. window.panelStore5 = Ext.create('Ext.data.Store', {  
  4.  fields:[{name:'name'},{name:'preStatics',type:'int'},'mypercent'],  
  5.     proxy: {  
  6.        type: 'ajax',  
  7.        url: extPath+'/center!getDetailByType.action?random='+new Date().getTime()+''+'&type=5',  
  8.        reader: {  
  9.            type: 'json',  
  10.            root: 'humresData',  
  11.            totalProperty: 'totalCount'  
  12.         }  
  13.   },  
  14.     autoLoad: false,  
  15.     sorters:[{  
  16.         property:"name",  
  17.         direction:"asc"  
  18.     },{  
  19.         property:"preStatics",  
  20.         direction:"asc"  
  21.       }],  
  22.   listeners:{  
  23.          beforeload:function(store,records,successful,operation,opts){  
  24.                  msgTip = Ext.MessageBox.show({  
  25.                   title:'提示',  
  26.                   width : 250,  
  27.                   msg:'页面统计信息刷新中,请稍后...',  
  28.                   buttons: Ext.Msg.OK  
  29.                   
  30.                  });  
  31.              },  
  32.         load:function(store,records,successful,operation,opts){  
  33.                 if(successful){  
  34.                     Ext.Msg.alert('提示','数据加载成功!');  
  35.                     msgTip.hide();  
  36.                       
  37.                 }else{  
  38.                       
  39.                     Ext.Msg.alert('提示','数据加载失败!');  
  40.                     msgTip.hide();  
  41.                 }          
  42.            }  
  43.   }  
  44. });    
  1. 服务器 返回数值 类似:{ 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 字段

   })

原文地址:https://www.cnblogs.com/dingjiaoyang/p/5207984.html