Ext数据交互的几种应用

【允许转载!但请注明出处!】 

1、FormPanel表单从后台加载数据


form.getForm().load({
         waitTitle:'提示',
         waitMsg : "正在加载数据……",
         url:'publicManage/organOperate.htm?method=organDetail',
         params:{         
          thiscode:thiscode
         },
         success:function(form,action){
          var record = action.result.data;
         },
         failure : function(form, action) {
       Ext.Msg.alert("提示","数据查询失败");
  }
});
使用这种方式需要表单项的name值与后台返回的json结果集中的对象名对应。否则数据加载不上。


2、FromPanel表单提交
Var values : Ext.encode(oneCustomerInfo_form.getForm().getValues());
//取form所有的Value值(json格式数据)
oneCustomerInfo_form.getForm().submit({   

        url:'customerInfoManage/oneCustomerInfo.htm?method=search',
        params:{

                      customername:oneCustomerInfo_form.getForm().findField('customername').getValue()
                      values: values
},                

        success:function(oneCustomerInfo_form,action){

                      var resultData = action.result.data;
                      alert(resultData['certno']);
},
 failure:function(response){
                      Ext.Msg.alert('失败','加载数据失败,无对应数据或者系统出现异常!');
 }
})


3、Ext的AJAX请求数据
Ext.Ajax.request({
      url:'publicManage/organOperate.htm?method=organClose',
      params:{
             thiscode:arrayCodes
      },
      success:function(response,option){     
             var obj = Ext.util.JSON.decode(response.responseText);  
             if(obj.success==true){

                    Ext.Msg.alert('提示',obj.msg);
             }else{
                    Ext.Msg.alert('提示',obj.errors);  
             }   
            //institutionRegist_GridStore.reload();
            //Ext.Msg.alert('消息','成功!'); 
      },
      failure:function(response,option){
             Ext.Msg.alert('失败',response.responseText);
      }
})


后台字符串通过Ext.util.JSON.decode 转成json字符串
不能自动根据json字符串success的值来选择流程 ,需要根据obj.success的值来判断走哪个流程

该failure:可以捕捉系统异常,比如,数据未曾提交到后台或action 不存在,此时走failure 流程

 

4、GridPanel加载数据
institutionRegist_GridStore.load({
       params: {
             start:0,

             limit:20,
           //limit:Ext.getCmp('institutionRegist_pPageSize').getValue(),   

             thiscode:institutionRegist_form.getForm().findField('from表单项的name').getValue()
       },            
       callback: function(data, options, success) {
             if (success) {
        
             } else {
                   Ext.Msg.alert("提示","加载数据失败,无对应数据或者系统出现异常!");
             }
       }

}) 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值