1 var MergeAction = new Ext.Action({ 2 text: ‘合并(选中两行)‘, 3 handler: function () { 4 if (grid.getSelectionModel().hasSelection()) { 5 var records = grid.getSelectionModel().getSelections();//获取选中的项 6 var count = records.length;//选中项的条数 7 if (count != 2) { 8 Ext.Msg.alert(‘温馨提示‘, ‘请检查选择的行数,当前选择了<font color="red">‘ + count + ‘行</font>,只能选择2行!‘); 9 return; 10 } else { 11 var numbers = new Array(); 12 for (var i = 0; i < records.length; i++) { 13 numbers[i] = records[i].data.AccidentNumber;//取得其中的数据 14 } 15 Ext.Msg.confirm(‘温馨提示‘, ‘是否确认合并选中项?‘, function (btn) { 16 if (btn == ‘yes‘) { 17 var numberA = numbers[0]; 18 var numberB = numbers[1]; 19 Ext.Ajax.request({ 20 url: ‘./AccidentArea/MergeAccident/MergeSameAccident‘, 21 params: { caseNoA: numberA, caseNoB: numberB }, 22 success: function (reponse) { 23 var result = Ext.decode(reponse.responseText); 24 Ext.Msg.alert(‘温馨提示‘, result.Message); 25 if (result.success) { 26 store.reload(); 27 } 28 }, 29 failure: function (response, options) { 30 var result = Ext.decode(response.responseText); 31 Ext.Msg.alert(‘温馨提示‘, result.error); 32 } 33 }); 34 } 35 }); 36 } 37 } else { 38 Ext.Msg.alert(‘温馨提示‘, ‘请选择需要合并的项!‘); 39 return; 40 } 41 }, 42 iconCls: ‘x-arrow_merge‘ 43 });
取得选中Grid的数据
时间: 2024-10-22 14:15:31