{ 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) { } });
}