基于Guns框架,表格做批量删除处理

首先上效果图:

1、打开对应页面的entity.js,将radio改为checkbox

2、在对应删除的JS中做如下处理:

Selection.delete = function () {
    if (this.check()) {
        var selected = $('#' + this.id).bootstrapTable('getSelections');
        var ids = "";
        for(var i = 0; i < selected.length; i++) {
            ids += selected[i].id + ",";
        }
        var ajax = new $ax(Feng.ctxPath + "/selection/delete", function (data) {
            Feng.success("删除成功!");
            Selection.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("ids", ids);
        ajax.start();
    }
};

3、Controller:

@RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam String ids) {
        String[] ss = ids.split(",");
        for (String s : ss) {
            selectionService.deleteById(Integer.valueOf(s));
        }
        return SUCCESS_TIP;
    }

这样就搞定了。

猜你喜欢

转载自blog.csdn.net/zgsdzczh/article/details/89556139