How to delete multiple rows in Jquery easyui datagrid
Front-end code
<Script type = "text/javascript"> $ (function () {$ ('# test '). datagrid ({title: 'style information', iconCls: 'icon-save', fit: true, nowrap: false, striped: true, // collapsible: true, url: '/GenerManage/LoadAllByPage/', sortName: 'genreid ', remoteSort: false, idField: 'genreid', frozenColumns: [[{field: 'ck', checkbox: true}], columns: [{field: 'genreid ', title: 'code', width: '80', align: 'center'}, {field: 'name', ti Tle: 'name', width: '20140901', align: 'left'}, {field: 'demotidtion ', title: 'description', width: '20140901', align: 'left'}], pagination: true, rownumbers: true, toolbar: [{id: 'btnadd', text: 'add', iconCls: 'icon-add ', handler: function () {this. href = '/GenerManage/View/'; }}, {id: 'btnupdate', text: 'modify', iconCls: 'icon-save', handler: function () {var rows = $ ('# test '). datagrid ('getselected'); if (rows) {this. href =" /GenerManage/View/"+ rows. genreId;} else {$. messager. alert ('hprompt ', 'select the data to modify'); return ;}}, '-', {id: 'btncut ', text: 'delete ', iconCls: 'icon-cut ', handler: function () {// obtain the table selection row var rows = $ (' # test '). datagrid ('getselections'); // determines whether to select the row if (! Rows | rows. length = 0) {$. messager. alert ('hprompt ', 'select the data to delete! ', 'Info'); return;} var parm; // returns a value for the submitted deletion parameter in a loop (music-style encoding) $. each (rows, function (I, n) {if (I = 0) {parm = "idList =" + n. genreId;} else {parm + = "& idList =" + n. genreId ;}}); $. messager. confirm ('hprompt ',' Do you want to delete the selected data? ', Function (r) {if (! R) {return;} // submit $. post ('/GenerManage/Delete/', parm, function (msg) {if (msg. isSuccess) {$. messager. alert ('hprompt ', msg. message, 'info', function () {// reload the current page $ ('# test '). datagrid ('reload');} else {$. messager. alert ('hprompt ', msg. message, 'info') }});}) ;}}]}); var p =$ ('# test '). datagrid ('getpager'); if (p) {$ (p ). pagination ({onBeforeRefresh: function () {alert ('before refresh ') ;}}}); </script>