Home > Web Front-end > JS Tutorial > body text

bootstrap implements deletion and batch deletion operations

PHPz
Release: 2018-10-13 15:07:03
Original
3189 people have browsed it

A record can be regarded as an array of data

1 Html

1.1 Batch selection box

1.2 Single delete

2 bootStarp

2.1 Batch acquisition

Get the selected data

//批量删除
function deleteUserList() {
    //获取所有被选中的记录
    var rows = $("#user").bootstrapTable('getSelections');
    if (rows.length== 0) {
        alert("请先选择要删除的记录!");
        return;
    }
    var ids = '';
    for (var i = 0; i < rows.length; i++) {
        ids += rows[i][&#39;id&#39;] + ",";
    }
    ids = ids.substring(0, ids.length - 1);
    deleteUser(ids);
}
Copy after login

2.2 Single acquisition

//单个删除
function deleteUserById(id) {
    deleteUser(id);
}
Copy after login

2.3 Public operation


//删除
function deleteUser(ids) {
    var msg = "您真的确定要删除吗?";
    if (confirm(msg) == true) {
        $.ajax({
            url: "${path}/user/deleteUserList.do",
            type: "post",
            data: {
                ids: ids
            },
            success: function (data) {
                alert(data.msg);
                //重新加载记录
                //重新加载数据
                $("#user").bootstrapTable(&#39;refresh&#39;, {url: &#39;/user/getUserList.do&#39;});
            }
        });
    }
}
Copy after login

3 Java

3.1 Controller

3.2 Service

##

public long deleteUserList(String ids) {
    String[] ss = ids.split(",");
    long count= 0;
    for (Strings : ss) {
        userResourceExtend.deleteUser(Integer.parseInt(s));
        count++;
    }
    return count;
}
Copy after login
3.3 dao

[Related video recommendations:

Bootstrap tutorial]

The above is the detailed content of bootstrap implements deletion and batch deletion operations. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template