`

遍历grid下某一个字段的总和

 
阅读更多
{
            layout : 'fit',
            height : 280,
            cm : planFinanceObjectMgr.planFinanceObjectCm,
            autoScroll : true,
            store : planFinanceObjectMgr.planFinanceStore,
            sm : new Ext.grid.CheckboxSelectionModel(),
            viewConfig : {
                forceFit : true
            },
            listeners : {
                render : function() {
                    Ext.getCmp('contract_htbuild_gridzjjh_ssum1').setValue(planFinanceObjectMgr.contract_htbuild_gridzjjh_ssum1);//todo::
                   var _record = 0;
                    planFinanceObjectMgr.BalanceMoneySum = 0;
                    __store=planFinanceObjectMgr.grid.getStore();
                    for (i = 0; i < __store.getCount(); i++) {
                        _record = __store.getAt(i).get('BalanceMoney');
                        if (_record != '' && isNaN(_record) == false) {
                            planFinanceObjectMgr.BalanceMoneySum += parseFloat(_record);
                        }
                    }
                    __distance = parseFloat(planFinanceObjectMgr.contract_htbuild_gridzjjh_ssum1) - parseFloat(planFinanceObjectMgr.BalanceMoneySum);

                    Ext.getCmp('contract_htbuild_gridzjjh_cesum1').setValue(__distance);
                }
            },
            tbar : [{
                text : "增加",
                iconCls : 'add',
                handler : function() {
                    planFinanceObjectMgr.financeID = "";
                    planFinanceObjectMgr.showEditForm();
                    planFinanceObjectMgr.getEditForm().getForm().reset();
                }
            }, {
                text : "修改",//WooI18N.ModuleBusiness.Contract.ContractButtonModifyText,
                iconCls : 'edit',
                handler : function() {
                    try {
                        var selectedKeys = planFinanceObjectMgr.grid.selModel.selections.keys;
                        if (selectedKeys.length != 1) {
                            Ext.MessageBox.alert("提示", "请选择一条要修改的数据");
                        } else {
                            planFinanceObjectMgr.financeID = planFinanceObjectMgr.grid.getSelectionModel().getSelected().get('ContractFinanceID');
                            Ext.Ajax.request({
                                url : 'BLL/ModuleBusiness/Contract/Operation.aspx?cmd=bindfinance',
                                method : 'POST',
                                params : {
                                    id : planFinanceObjectMgr.financeID
                                },
                                failure : function(response, options) {
                                    Ext.MessageBox.hide();
                                    Ext.MessageBox.alert("警告", "修改失败");
                                },
                                success : function(response, options) {
                                    Ext.MessageBox.hide();
                                    var formValue = Ext.decode(response.responseText);
                                    //给编辑页面Form赋值
                                    planFinanceObjectMgr.showEditForm();
                                    Ext.getCmp('sm_TARGETNAME').setValue(formValue.SUBJ_ID);//标的
                                    Ext.getCmp('FINACE_NAME_formid').setValue(formValue.FINACE_NAME);//计划资金名称
                                    Ext.getCmp('zj_je_formid').setValue(formValue.zj_je);//计划金额
                                    Ext.getCmp('zj_date_formid').setValue(formValue.zj_date);//计划完成时间
                                    Ext.getCmp('zj_jsfs_formid').setValue(formValue.zj_jsfs);//自定义结算方式名称
                                    Ext.getCmp('SETTLEMENT_CATEGORY_ID_formid').setValue(formValue.SETTLEMENT_CATEGORY_ID);//自定义结算方式Id
                                    Ext.getCmp('remark_formid').setValue(formValue.remark);//备注
                                    Ext.getCmp('contract_htbuild_savezj').disabled = false;
                                }
                            });
                        }
                    }
                    catch (e) {
                        alert(e + '\n\r\n\r' + e.stack)
                    }
                }
            }, {
                text : WooI18N.ModuleBusiness.Contract.ContractButtonDeleteText,//financeok
                iconCls : 'remove',
                handler : function() {
                    var selectedKeys = planFinanceObjectMgr.grid.selModel.selections.keys;
                    if (selectedKeys.length > 0) {
                        Ext.MessageBox.confirm("提示", "是否要删除", function(btn) {
                            if (btn != 'yes') {
                                return;
                            } else {
                                var selectedRows = planFinanceObjectMgr.grid.getSelections();
                                var restip = "";
                                var ids = "";
                                if (selectedRows) {
                                    for (var i = 0; i < selectedRows.length; i++) {
                                        var id = selectedRows[i].get('ContractFinanceID');
                                        ids += id + ",";
                                    }
                                }
                                Ext.Ajax.request({
                                    url : "BLL/ModuleBusiness/Finance/Operation.aspx?cmd=DeleteContractJe",
                                    params : {
                                        id : ids
                                    },
                                    failure : function(response, options) {
                                        Ext.MessageBox.hide();
                                        Ext.MessageBox.alert("警告", "请求失败");
                                    },
                                    success : function(response, options) {
                                        switch (response.responseText) {
                                            case "108" :
                                                restip = WooI18N.ModuleBusiness.Contract.NotDeleteRemark;//'合同的状态为"已完成、已终止、已作废"不能删除备忘'
                                                break;
                                            case "109" :
                                                restip = WooI18N.ModuleBusiness.Contract.ObjectDeleteFailure;// '删除失败!';
                                                break;
                                            case "110" :
                                                restip = WooI18N.ModuleBusiness.Contract.ObjectDeleteSuccess;//'删除成功!';
                                                break;
                                            case "111" :
                                                restip = WooI18N.ModuleBusiness.Contract.NotTimeDeleteRemark;// '某些说明不能删除!已经超过24小时。';
                                                break;
                                            case "112" :
                                                restip = WooI18N.ModuleBusiness.Contract.NotDeleteFile;// '合同的状态为"已完成、已终止、已作废"不能删除附件';
                                                break;
                                            case "113" :
                                                restip = WooI18N.ModuleBusiness.Contract.NotTimeDeleteFile;// '某些附件不能删除!已经超过24小时。';
                                                break;
                                            case "146" :
                                                restip = WooI18N.ModuleBusiness.Contract.SomeHaveFinance;//某些计划资金下存在实际资金或进度!
                                                break;
                                        }
                                        planFinanceObjectMgr.planFinanceStore.reload();
                                        Woo.Common.operationNotice(planFinanceObjectMgr.grid, restip);
                                    }
                                });
                            }
                        })
                    } else {
                        Ext.MessageBox.alert("提示", "请选择要删除的数据")
                    }
                }
            }],
            bbar : ['->', "标的合计:", {
                xtype : 'textfield',
                style : 'border:0;background:none;color:black;',
                id : 'contract_htbuild_gridzjjh_ssum1',
                name : 'contract_htbuild_gridzjjh_ssum1',
                readOnly : true,
                width : 100,
                value : 0
            }, "计划资金与金额与合同标的的差额:", {
                xtype : 'textfield',
                style : 'border:0;background:none;color:black;',
                id : 'contract_htbuild_gridzjjh_cesum1',
                name : 'contract_htbuild_gridzjjh_cesum1',
                readOnly : true,
                width : 100,
                value : 0
            }]
        }



``````````````````````````````````````````````````另外一个例子,和上面的没有关系 了

planFinanceObjectMgr.ContractFinanceMoney = planFinanceObjectMgr.getGrid().getStore().sum('ContractFinanceMoney');//这一句等价于下面的一大堆
                                    //                                    var __store = planFinanceObjectMgr.grid.getStore();
                                    //                                    for (i = 0; i < __store.getCount(); i++) {
                                    //                                        _record = __store.getAt(i).get('ContractFinanceMoney');
                                    //                                        if (_record != '' && isNaN(_record) == false) {
                                    //                                            planFinanceObjectMgr.ContractFinanceMoney += parseFloat(_record);
                                    //                                        }
                                    //                                    }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics