Jquery easyui datagrid 刪除多行問題

前臺代碼

<script type="text/javascript">
$(function () {
$('#test').datagrid({
title: '風格信息',
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: '編碼', width: '80', align: 'center' },
                    { field: 'Name', title: '名稱', width: '200', align: 'left' },
{ field: 'Desctiption', title: '描述', width: '350', align: 'left' }
                ]],
pagination: true,
rownumbers: true,
toolbar: [{
id: 'btnadd',
text: '添加',
iconCls: 'icon-add',
handler: function () {
this.href = '/GenerManage/View/';
}
}, {
id: 'btnupdate',
text: '修改',
iconCls: 'icon-save',
handler: function () {
var rows = $('#test').datagrid('getSelected');
if (rows) {
this.href = "/GenerManage/View/" + rows.GenreId;
}
else {
$.messager.alert('提示', '請選擇要修改的數據');
return;
}
}
}, '-', {
id: 'btncut',
text: '刪除',
iconCls: 'icon-cut',
handler: function () {
//獲取表格選擇行
var rows = $('#test').datagrid('getSelections');
//判斷是否選擇行
if (!rows || rows.length == 0) {
$.messager.alert('提示', '請選擇要刪除的數據!', 'info');
return;
}
 
var parm;
//循環給提交刪除參數賦值(音樂風格編碼)
$.each(rows, function (i, n) {
if (i == 0) {
parm = "idList=" + n.GenreId;
} else {
parm += "&idList=" + n.GenreId;
}
});
$.messager.confirm('提示', '是否刪除選中數據?', function (r) {
if (!r) {
return;
}
//提交
$.post('/GenerManage/Delete/', parm,
function (msg) {
if (msg.IsSuccess) {
$.messager.alert('提示', msg.Message, 'info', function () {
//重新加載當前頁
$('#test').datagrid('reload');
});
} else {
$.messager.alert('提示', msg.Message, 'info')
}
});
});
}
}]
});
var p = $('#test').datagrid('getPager');
if (p) {
$(p).pagination({
onBeforeRefresh: function () {
alert('before refresh');
}
});
}
});
</script>

2012070418194751.png

2012070418201649.png

刪除成功

2012070418204645.png






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章