Extjs EditorGridPanel

 //手动下发
        
//            var data = [{ ISSBANK: "Issbank", ISSBRANCHBANK: "issbanchbank", CARDNUM: "cardnum", CARDHOLDER: "cardholder", AMOUNT: 8.56, MERDETAILREFNUM: "merdetailrefunm", MERREMARK: "merremark"}];
            var data = [];
            var ds = new Ext.data.JsonStore({
                data: data,
                fields: ["ISSBANK", "ISSBRANCHBANK", "CARDNUM", "CARDHOLDER", { name: "AMOUNT", type: "float" }, "MERDETAILREFNUM", "MERREMARK"]
            });
            var cm = new Ext.grid.ColumnModel([
            new Ext.grid.RowNumberer(),
            { header: '<% = GetLocalResourceObject("IssbankText") %>', dataIndex: "ISSBANK", sortable: true, width: 100, editor: new Ext.form.TextField({ allowBlank: false, regex: /^\S+$/ }) },
            { header: '<% = GetLocalResourceObject("IssubbakText") %>', dataIndex: "ISSBRANCHBANK", width: 100, editor: new Ext.form.TextField({ allowBlank: false, regex: /^\S+$/ }) },
            { header: '<% = GetLocalResourceObject("AccountText") %>', dataIndex: "CARDNUM", width: 100, editor: new Ext.form.TextField({ allowBlank: false, regex: /^\S+$/ }) },
            { header: '<% = GetLocalResourceObject("IssNameText") %>', dataIndex: "CARDHOLDER", width: 100, editor: new Ext.form.TextField({ allowBlank: false, regex: /^\S+$/ }) },
            { header: '<% = GetLocalResourceObject("MoneyText") %>', dataIndex: "AMOUNT", width: 100, editor: new Ext.form.NumberField({ align: 'right', allowBlank: false, regex: /^\S+$/, minValue: 0.1, allowNegative: false }) },
            { header: '<% = GetLocalResourceObject("MerBatRefnumText") %>', dataIndex: "MERDETAILREFNUM", width: 100, editor: new Ext.form.TextField({ allowBlank: false, regex: /^\S+$/ }) },
            { header: '<% = GetLocalResourceObject("MemoText") %>', dataIndex: "MERREMARK", width: 100, editor: new Ext.form.TextField({ }) }
         ]);


            var manualForm = new Ext.grid.EditorGridPanel({
                width: 700,
                height: 350,
                frame: true,
                //licksToEdit: 2,
                store: ds,
                cm: cm
            });

这个grid嵌套在一个window中

   //手动下发
        
//            var data = [{ ISSBANK: "Issbank", ISSBRANCHBANK: "issbanchbank", CARDNUM: "cardnum", CARDHOLDER: "cardholder", AMOUNT: 8.56, MERDETAILREFNUM: "merdetailrefunm", MERREMARK: "merremark"}];
            var data = [];
            var ds = new Ext.data.JsonStore({
                data: data,
                fields: ["ISSBANK", "ISSBRANCHBANK", "CARDNUM", "CARDHOLDER", { name: "AMOUNT", type: "float" }, "MERDETAILREFNUM", "MERREMARK"]
            });
            var cm = new Ext.grid.ColumnModel([
            new Ext.grid.RowNumberer(),
            { header: '<% = GetLocalResourceObject("IssbankText") %>', dataIndex: "ISSBANK", sortable: true, width: 100, editor: new Ext.form.TextField({ allowBlank: false, regex: /^\S+$/ }) },
            { header: '<% = GetLocalResourceObject("IssubbakText") %>', dataIndex: "ISSBRANCHBANK", width: 100, editor: new Ext.form.TextField({ allowBlank: false, regex: /^\S+$/ }) },
            { header: '<% = GetLocalResourceObject("AccountText") %>', dataIndex: "CARDNUM", width: 100, editor: new Ext.form.TextField({ allowBlank: false, regex: /^\S+$/ }) },
            { header: '<% = GetLocalResourceObject("IssNameText") %>', dataIndex: "CARDHOLDER", width: 100, editor: new Ext.form.TextField({ allowBlank: false, regex: /^\S+$/ }) },
            { header: '<% = GetLocalResourceObject("MoneyText") %>', dataIndex: "AMOUNT", width: 100, editor: new Ext.form.NumberField({ align: 'right', allowBlank: false, regex: /^\S+$/, minValue: 0.1, allowNegative: false }) },
            { header: '<% = GetLocalResourceObject("MerBatRefnumText") %>', dataIndex: "MERDETAILREFNUM", width: 100, editor: new Ext.form.TextField({ allowBlank: false, regex: /^\S+$/ }) },
            { header: '<% = GetLocalResourceObject("MemoText") %>', dataIndex: "MERREMARK", width: 100, editor: new Ext.form.TextField({ }) }
         ]);


            var manualForm = new Ext.grid.EditorGridPanel({
                width: 700,
                height: 350,
                frame: true,
                //licksToEdit: 2,
                store: ds,
                cm: cm
            });

            var manualAllForm = new Ext.FormPanel({
                id: "frm3",
                autoHeight: true,
                width: 720,
                frame: true,
                items: [
                   new Ext.form.NumberField({
                       id: "txtIssuedNum",
                       fieldLabel: '<% = GetLocalResourceObject("WriteAddRecordText") %>',
                       allowDecimals: false,               //不允许输入小数  
                       nanText: '<% = GetLocalResourceObject("WriteIntText") %>',           //无效数字提示  
                       allowNegative: false,              //不允许输入负数  
                       maxValue: 100,                       //最大值  
                       minValue: 1                      //最小值                
                   }),
                  new Ext.Button({
                      text: '<% = GetLocalResourceObject("SaveText") %>',
                      handler: function () {
                          var num = Ext.getCmp("txtIssuedNum").getValue();
                          if (num < 1) return false;
                          var count = ds.getCount();

                          if (count == num) { return false; }
                          else if (count < num) {
                              var o = num - count;
                              for (var i = 0; i < o; i++) {
                                  var iss = new ds.recordType({
                                      ISSBANK: "",
                                      ISSBRANCHBANK: "",
                                      CARDNUM: "",
                                      CARDHOLDER: "",
                                      AMOUNT: 0.00,
                                      MERDETAILREFNUM: "",
                                      MERREMARK: ""
                                  });
                                  ds.addSorted(iss);
                              }
                          }
                          else {
                              var oo = count - num;
                              for (var i = 0; i < oo; i++) {
                                  ds.remove(ds.getAt(count - oo));
                              }
                          }

                      }
                  }),
              manualForm
               ],
                buttons: [{
                    text: '<% = GetLocalResourceObject("SaveInfoText") %>',
                    handler: function () {
                        var co = ds.getCount();
                        if (co == 0) { Ext.Msg.alert('<% = GetLocalResourceObject("WarnText") %>', '<% = GetLocalResourceObject("WriteRecordText") %>'); return false; }
                        var array = new Array();
                        ds.each(function (record) {
                            array.push(record.data);
                        });
                        var enable = true;
                        for (var i = 0; i < array.length; i++) {
                            var arr = array[i];
                            if (arr.ISSBANK == "" || arr.ISSBRANCHBANK == "" || arr.CARDNUM == "" || arr.CARDHOLDER == "" || arr.AMOUNT < 0.1 || arr.MERDETAILREFNUM == "") {
                                enable = false;
                            }
                        }
                        if (!enable) {
                            Ext.Msg.alert('<% = GetLocalResourceObject("PromptText") %>', '<% = GetLocalResourceObject("WriteFullDataText") %>'); return false;
                        }
                        Ext.Ajax.request({
                            url: "../Handler/Issued.ashx",
                            params: {
                                method: "SaveInfo",
                                dataStore: Ext.util.JSON.encode(array)
                            },
                            success: function (response, option) {
                                var result = Ext.util.JSON.decode(response.responseText);
                                if (result.Flag == true) {
                                    Ext.Msg.alert("Success", '<% = GetLocalResourceObject("IssuedSuccessText") %>');
                                    ds.removeAll();
                                    MerBatchStore.load();
                                } else {
                                    Ext.Msg.alert("Fail", result.RespMessage);
                                }
                            },
                            failure: function (response, option) {
                                Ext.Msg.alert("Failed", result.RespMessage);
                            }
                        });
                    }
                }, {
                    text: '<% = GetLocalResourceObject("SaveApproveText") %>',
                    handler: function () {
                        var co = ds.getCount();
                        if (co == 0) { Ext.Msg.alert('<% = GetLocalResourceObject("WarnText") %>', '<% = GetLocalResourceObject("WriteRecordText") %>'); return false; }
                        var array = new Array();
                        ds.each(function (record) {
                            array.push(record.data);
                        });
                        Ext.Ajax.request({
                            url: "../Handler/Issued.ashx",
                            params: {
                                method: "SaveApproveText",
                                dataStore: Ext.util.JSON.encode(array)
                            },
                            success: function (response, option) {
                                var result = Ext.util.JSON.decode(response.responseText);
                                if (result.Flag == true) {
                                    Ext.Msg.alert("Success", '<% = GetLocalResourceObject("IssuedSuccessText") %>');
                                    ds.removeAll();
                                } else {
                                    Ext.Msg.alert("Fail", result.RespMessage);
                                }
                            },
                            failure: function (response, option) {
                                Ext.Msg.alert("Failed", result.RespMessage);
                            }
                        });
                    }
                }]

            });
 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值