easyUI批量删除,向后台传数组

来源:互联网 发布:哪个软件直播笑傲江湖 编辑:程序博客网 时间:2024/04/30 09:14

easyUI做批量删除时,向后台传送数组

前台代码:

<table id="dg" class="easyui-datagrid" title="分行信息" style="width:1200px;height:450px"
            data-options="
            rownumbers:true,
            singleSelect:true,
            url:'${ctx}/branchAjax',
            method:'get',
            autoRowHeight:false,
            pagination:true,
            pageSize:10,
            toolbar:'#tb'">
        <thead>
            <tr>
                <th data-options="field:'id',checkbox:true">ID</th>
                <th data-options="field:'branch_code',width:100">分行编码</th>
                <th data-options="field:'branch_name',width:80,align:'right'">分行名称</th>
                <th data-options="field:'simple_name',width:80,align:'right'">分行简称</th>
                <th data-options="field:'english_name',width:220">外文名称</th>
                <th data-options="field:'district_code',width:220">地区编码</th>
                <th data-options="field:'create_date',width:220">成立日期</th>
                <th data-options="field:'branch_state',width:60,align:'center'">状态</th>
            </tr>
        </thead>
    </table>

js代码:

function deleteDate(){

            var rows = $('#dg').datagrid('getSelections');  
            var ids = new Array();
            for(var i=0; i<rows.length; i++){  
                ids.push(rows[i].id);
            }  
            $.ajax({
                 type: "POST",
                 url: "${ctx}/deleteBranch",
                 data: { "ids": ids},
                 dataType: "json",
                 traditional: true,
                 success: function(data){
                     window.location.reload();
                 },
                 error : function() {  
                              alert("异常!");  
                 }
            });

        }

后台接收代码:

public void deleteBranch(int[] ids, HttpServletRequest request) {
        for (int i : ids) {
            tBrenchService.deleteBranch(i);
        }
    }


0 0