easyui datagrid 获取多条选中的数据进行操作
function topCenter(msg) {
$.messager.show({
title: '提示',
msg: msg,
showType: 'slide',
style: {
right: '',
top: document.body.scrollTop + document.documentElement.scrollTop,
bottom: ''
}
});
}
function warning(msg) {
$.messager.alert('提示', msg, 'warning');
}
function confirmMsg(msg,func) {
$.messager.confirm('提示', msg, function (r) {
if (r) {
func();
}
});
}
function datagridFun(dg, url, fun) {
var param1, param2, param3;
switch (arguments.length) {
case 2: param1 = param2 = param3 = null; break;
case 3: param1 = arguments[2]; param2 = param3 = null; break;
case 4: param1 = arguments[2]; param2 = arguments[3]; param3 = null; break;
case 5: param1 = arguments[2]; param2 = arguments[3]; param3 = arguments[4]; break;
}
var datagrid = $('#'+dg);
var rows = datagrid.datagrid('getSelections');
if (rows.length <= 0) {
warning('请选中您要操作的数据!');
}
else {
confirmMsg('您共选择了' + rows.length + '条记录,继续吗?', function () {
var ids = [];
for (var i = 0, j = rows.length; i < j; i++) {
ids.push(rows[i].id);
}
ids.join(',');
$.post(url, { id: ids.toString(), operator: $.cookie('user'),param1:param1,param2:param2,param3:param3 }, function (result) {
if (result.success) {
topCenter(result.msg); datagrid.datagrid('reload'); $('#recentOp').datagrid('reload');
if(fun != undefined) fun();
} else {
warning(result.msg);
}
}, 'json')
})
}
}