使用jqgrid 删除后返回信息。

JS代码

        function ondelRow(){
             var ids=$("#table_list").jqGrid("getGridParam","selarrrow");//获取选中的行(数组)
                if(ids.length>0){
                    var id = ids.toString();
                 $.post("${ctx}/pems/property/deleteAll",{"ids":id},function(data) {
                     var s=2;
                     if(data.indexOf("除成")>0){
                         s=1;
                     }
                        layer.msg(data, {icon:s});
                        refresh();
                     });
               }else{
                    layer.alert('请先选择数据', {
                          skin: 'demo-class',
                          icon: 2,
                          time: 3500,
                          title:'提示',
                          offset: '150px',
                          closeBtn: 0
                        })
                }
        }

JSP代码

<button class="my_button btn" οnclick="ondelRow()" data-toggle="tooltip" data-placement="top"><i class="fa fa-trash-o"> 删除</i> </button>

后台代码

    @ResponseBody //注解,自动将string转换成json返回给ajax
    @RequiresPermissions("pems:property:del")
    @RequestMapping(value = "deleteAll")
    public String deleteAll(String ids, Model model) {
        String idArray[] =ids.split(",");
        int code=0;
        int sum=0;
        for(String id : idArray){
             Building judge = buildingService.selectById1(propertyService.get(id).getId());
             //判断如果物业下没有楼座就可以删除
             if(judge==null){
                    try{
                         code = propertyService.delete10(propertyService.get(id));
                        if (code!=1) {
                            return "删除失败,请联系管理员";
                        }else {
                            sum+=1;
                        }
                    }catch(Exception e){
                        return "系统错误,请联系管理员";
                    }
//                 propertyService.delete(propertyService.get(id));
            }else{
                return "成功删除"+sum+"条数据!"+ "物业"+propertyService.get(id).getName()+"下有楼座,不能删除";
//                return "redirect:"+adminPath+"/pems/property/list?repage";
            }
        }
        return "删除成功"+sum+"条数据!";

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

华洛

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值