多删,连删的实现
前端页面实现
<table border="1" id="dataList" class="table table-bordered table-striped table-hover dataTable">
<thead>
<tr>
<th class="" style="padding-right:0px">
<input id="selall" type="checkbox" class="icheckbox_square-blue">
</th>
<th class="sorting_asc">ID</th>
<th class="sorting">名称</th>
<th class="sorting">首字母</th>
<th class="text-center">操作</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="entity in list">
<td><input type="checkbox" ng-click="updateStatus($event,entity.id)"></td>
<td>{{entity.id}}</td>
<td>{{entity.name}}</td>
<td>{{entity.firstChar}}</td>
<td class="text-center">
<button type="button" class="btn bg-olive btn-xs" data-toggle="modal" data-target="#editModal" ng-click="findOne(entity.id)" >修改</button>
</td>
</tr>
</tbody>
前端controller层的代码
$scope.selectedIds=[];
$scope.dele=function(){
//alert($scope.selectedIds);
shoujiService.dele($scope.selectedIds).success(function(resp){
if(resp.isSuccess){
//刷新列表
$scope.getList();
}else{
$scope.getList();
alert(resp.message);
}
});
}
$scope.updateStatus=function($event,id) {
alert(id)
if($event.target.checked){
//刷新列表
$scope.selectedIds.push(id);
//alert($scope.selectedIds);
}else{
var idx=$scope.selectedIds.indexOf(id);
$scope.selectedIds.slice(idx,1);
}
}
前端service层的代码
this.dele=function(id){
return $http.get("/day0721/shouji/dele.do?id="+id);
}
后端controller层的代码
@RequestMapping("/dele.do")
@ResponseBody
public Result dele(String id) {
//System.out.println(id);
try {
shoujiService.dele(id);
return new Result(true, "删除业务执行成功");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return new Result(false, "删除业务执行失败");
}
后端service层的代码
@Override
public void dele(String id) {
// TODO Auto-generated method stub
String[] result1 = id.split(",");
for(int i = 0; i < result1.length; i++) {
shoujiMapper.deleteByPrimaryKey(Long.parseLong(result1[i]));
}
}
实现