grid可编辑修改执行操作和判断

{
    xtype: 'grid',
    id: 'grid',
    flex: 1,
    // height : window.screen.height/2-50,
    height: 300,
    width:'100%',
    store: 'gridStore',
    columnLines: true,
    selType: 'checkboxmodel',
    multiSelect: true,
    autoScroll: true,
    //width: window.screen.width / 2 - 50,
    plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
        clicksToEdit: 1,
        listeners: {
            validateedit:OnCompareElem,
            edit: OnChangePlanAmount
        }
    })],
    columns: [
        {
            text: '序号',
            xtype: 'rownumberer',
            align: 'center',
            width: 40
        },
        {
            text: '工序',
            width: 50,
            align: 'center',
            dataIndex: 'V_ACTIVITY',
            renderer: AddFloat
        },
        {
            text: '物料编码',
            flex: 2,
            align: 'center',
            dataIndex: 'V_MATERIALCODE',
            renderer: AddFloat
        },
        {
            text: '物料描述',
            flex: 4,
            align: 'center',
            dataIndex: 'V_MATERIALNAME',
            renderer: AddFloat
        },
        {
            text: '单位',
            width: 40,
            align: 'center',
            dataIndex: 'V_UNIT',
            renderer: AddFloat
        },
        {
            text: '计划数量',
            width: 60,
            align: 'center',
            dataIndex: 'I_PLANAMOUNT',
            field: {
                id: 'jhsl',
                xtype: 'numberfield',
                minValue: 0.0001,
                allowDecimals: true,
                decimalPrecision: 8
            },
            renderer: IsEdit   //可编辑的列
        },
        {
            text: '计划总金额',
            width: 80,
            align: 'center',
            dataIndex: 'F_PLANMONEY',
            renderer: function (value, metaData, record, rowIdx, colIdx,
                                store, view) {
                return '<div style="text-align:right;">'
                    + Ext.util.Format.usMoney(record
                        .get('I_PLANAMOUNT')
                    * record.get('F_UNITPRICE')) + '</div>';
            }
        }, {
            text: '备注',
            width: 160,
            align: 'center',
            dataIndex: 'V_MEMO',
            field: {
                id: 'mem',
                xtype: 'textfield'
            },
            renderer: AddFloat
        }],
    features: [{
        ftype: 'summary'
    }]
}

//grid可编辑值改变与否判断

function OnCompareElem ( editor, context, eOpts ){
//用于判断grid可编辑时候原值和输入值是否发生变化
    if(context.originalValue==context.value&&setMatSign==0){
        setMatSign=0; //若只是点击编辑,其值未改变则为0
    }else{
        setMatSign=1;
    }
    Ext.Ajax.request({
        url:AppUrl+'dxfile/PRO_WORKORDER_MAT_CHANGE_SIGN_IN',
        type:'POST',
        async:false,
        params:{
            V_WORKGUID:V_ORDERGUID,
            V_SIGN:setMatSign
        },
        success:function(ret){
            var resp=Ext.decode(ret.responseText);
        }
    });

}

//若编辑则执行如下操作

function OnChangePlanAmount(editor, e, eOpts) {
   // 可取对应编辑行的列的值e.record.data.对应data
    Ext.Ajax
        .request({
            type: 'ajax',
            url: AppUrl + 'zdh/PRO_PM_WORKORDER_SPARE_SET',
            method: 'POST',
            async: false,
            params: {
                V_I_ID: e.record.data.I_ID,
                V_V_ORDERGUID: V_ORDERGUID,
                V_V_FETCHORDERGUID: '',
                V_V_ACTIVITY: e.record.data.V_ACTIVITY,
                V_V_MATERIALCODE: e.record.data.V_MATERIALCODE,
                V_V_MATERIALNAME: e.record.data.V_MATERIALNAME,
                V_V_SPEC: e.record.data.I_ID,
                V_V_UNIT: e.record.data.V_UNIT,
                V_F_UNITPRICE: e.record.data.F_UNITPRICE,
                V_I_PLANAMOUNT:e.record.data.I_PLANAMOUNT,
                V_F_PLANMONEY: str,
                V_I_ACTUALAMOUNT:'0',
                V_F_ACTUALMONEY: '0',
                V_V_TYPE: '',
                V_V_MEMO: e.record.data.V_MEMO,
                V_V_SUBTYPE: '',
                V_V_STATUS: '',
                V_I_ABANDONEDAMOUNT: '0',
                V_I_RECLAIMEDAMOUNT: '0',
                V_I_FIXEDAMOUNT: '0',
                V_V_ID: ''
            },
            success: function (response) {
            }
        });

}

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值