当前位置:网站首页>EasyUI DataGrid obtains multiple selected data for operation

EasyUI DataGrid obtains multiple selected data for operation

2022-07-26 22:09:00 reg183

easyui datagrid Obtain multiple selected data for operation

function topCenter(msg) {
    
    $.messager.show({
    
        title: ' Tips ',
        msg: msg,
        showType: 'slide',
        style: {
    
            right: '',
            top: document.body.scrollTop + document.documentElement.scrollTop,
            bottom: ''
        }
    });
}
function warning(msg) {
    
    $.messager.alert(' Tips ', msg, 'warning');
}
function confirmMsg(msg,func) {
    
    $.messager.confirm(' Tips ', 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(' Please select the data you want to operate !');
    }
    else {
    
        confirmMsg(' You have selected ' + rows.length + ' Bar record , Go ahead ?', 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')
        })
    }
}
原网站

版权声明
本文为[reg183]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/207/202207262114513027.html