easyui datagrid 批量编辑保存删除

  1. $("#tt").datagrid({  
  2.     title: '批次',  
  3.     url: '',  
  4.     method: 'get',  
  5.     idfield: '宿舍号',  
  6.     pagination: false,  
  7.     iconCls: 'icon-save',  
  8.     rownumbers: true,  
  9.     pageSize: 10000,  
  10.     pageList: [15, 30],  
  11.     toolbar: '#tb',  
  12.     striped: true,  
  13.     fitcolumns: true,  
  14.     //nowarp: false,  
  15.     singleSelect: true,  
  16.     columns: [[  
  17.             {  
  18.                 title: '年度',  
  19.                 field: '年度',  
  20.                 width: 60,  
  21.                 editor: {  
  22.                     type: 'combobox',  
  23.                     options: {  
  24.                         required: true,  
  25.                         missingMessage: 'ccccc',  
  26.                         multiple: false,  
  27.                         editable: false,  
  28.                         valueField: 'VALUE',  
  29.                         textField: '年度',  
  30.                         url: '../ComService.ashx/ProcessRequest?method=GetYearComboData'  
  31.                     }  
  32.                 }  
  33.             },  
  34.             {  
  35.                 title: '培养层次',  
  36.                 field: '培养层次',  
  37.                 width: 80,  
  38.                 editor: {  
  39.                     type: 'combobox',  
  40.                     options: {  
  41.                         required: true,  
  42.                         missingMessage: '请选择培养层次',  
  43.                         multiple: false,  
  44.                         editable: false,  
  45.                         valueField: 'id',  
  46.                         textField: 'text',  
  47.                         data: [{ 'id''本科生''text''本科生' }, { 'id''研究生''text''研究生'}]  
  48.                     }  
  49.                 }  
  50.             },  
  51.             {  
  52.                 title: '就学地',  
  53.                 field: '就学地',  
  54.                 width: 80,  
  55.                 editor: {  
  56.                     type: 'combobox',  
  57.                     options: {  
  58.                         required: true,  
  59.                         missingMessage: '请选择就学地',  
  60.                         multiple: false,  
  61.                         editable: false,  
  62.                         valueField: 'id',  
  63.                         textField: 'text',  
  64.                         data: [{ 'id''本部''text''本部' }, { 'id''暨阳''text''暨阳'}]  
  65.                     }  
  66.                 }  
  67.             },  
  68.             {  
  69.                 title: '批次名称',  
  70.                 field: '批次名称',  
  71.                 width: 150  
  72.             },  
  73.             {  
  74.                 title: '修改',  
  75.                 field: 'edit',  
  76.                 width: 60,  
  77.                 formatter: function (value, row, index) {  
  78.                     if (row.editing) {  
  79.                         var editLink = '<input type="button" value="保存" οnclick="doSave(' + index + ')">';  
  80.                         return editLink;  
  81.                     } else {  
  82.                         var editLink = '<input type="button" value="修改" οnclick="doEdit(' + index + ')">';  
  83.                         return editLink;  
  84.                     }  
  85.                 }  
  86.             },  
  87.             {  
  88.                 title: '删除',  
  89.                 field: 'del',  
  90.                 width: 60,  
  91.                 formatter: function (value, row, index) {  
  92.                     if (row.editing) {  
  93.                         var editLink = '<input type="button" value="取消" οnclick="doCancel(' + index + ')">';  
  94.                         return editLink;  
  95.                     } else {  
  96.                         var delLink = '<input type="button" value="删除" οnclick="doDelete(\'' + row['批次名称'] + '\')">';  
  97.                         return delLink;  
  98.                     }  
  99.                 }  
  100.             }  
  101.         ]],  
  102.     onAfterEdit: function (rowIndex, rowData, changes) {  
  103.         //endEdit该方法触发此事件  
  104.         alert(changes);  
  105.         editRow = undefined;  
  106.     },  
  107.     onBeforeEdit: function (index, row) {  
  108.         row.editing = true;  
  109.         $('#tt').datagrid('refreshRow', index);  
  110.     },  
  111.     onAfterEdit: function (index, row) {  
  112.         row.editing = false;  
  113.         $('#tt').datagrid('refreshRow', index);  
  114.     },  
  115.     onCancelEdit: function (index, row) {  
  116.         row.editing = false;  
  117.         $('#tt').datagrid('refreshRow', index);  
  118.     }  
  119. });  
  120. initTT 

  1. var editRow = undefined;  
  2. function doEdit(index) {  
  3.     if (editRow != undefined) {  
  4.         $("#tt").datagrid('cancelEdit', editRow);  
  5.         editRow = undefined;  
  6.     }  
  7.   
  8.     $("#tt").datagrid('selectRow', index);  
  9.     var rows = $("#tt").datagrid('getSelections');  
  10.     if (rows.length == 1) {  
  11.         if (editRow == undefined) {;  
  12.             $("#tt").datagrid('beginEdit', index);  
  13.             editRow = index;  
  14.         }  
  15.     }  
  16. }  
  17. function doSave(index) {  
  18.     $("#tt").datagrid('endEdit', index);  
  19.     editRow = undefined;  
  20. }  
  21. function doCancel(index) {  
  22.     $("#tt").datagrid('cancelEdit', index);  
  23.     editRow = undefined;  
  24. }  
  25. function doDelete(pcname) {  
  26.     if (editRow != undefined) {  
  27.         $("#tt").datagrid('cancelEdit', editRow);  
  28.         editRow = undefined;  
  29.     }  
  30.   
  31.     $.messager.confirm('确认''你真的要删除该批次名称吗?'function (r) {  
  32.         if (r) {  
  33.             $.ajax({  
  34.                 type: "post",  
  35.                 url: "PiciService.ashx/ProcessRequest?method=Delete" + "&pcmc=" + pcname,  
  36.                 data: null,  
  37.                 success: function (result) {  
  38.                     if (result.Success) {  
  39.                         $.messager.alert("提示""删除成功!""info");  
  40.   
  41.                         getAllData();  
  42.                     }  
  43.                     else {  
  44.                         $.messager.alert("错误", result.Msg, "info");  
  45.                     }  
  46.                 },  
  47.                 dataType: "json"  
  48.             });  
  49.         }  
  50.     });  


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值