码迷,mamicode.com
首页 > Web开发 > 详细

json格式实现批量删除

时间:2014-08-26 11:13:15      阅读:384      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   for   ar   div   

前端代码,将删除记录序列号组合成字符串传到后台

 ‘industryList button[action=deleteAll]‘ : {
                    click : function(button){
                    //    var agrid = button.findParentByType("gridpanel");
                        var agrid = button.ownerCt.ownerCt;
                        var data = agrid.getSelectionModel( ).getSelection();
                        if(data.length == 0){
                            Ext.Msg.alert(‘警告‘,‘请选择记录‘);
                        }else{
                            var mystore = agrid.getStore();
                            var aarray = [ ];
                            //序列号组合成字符串数组
                            Ext.Array.each(data,function(record){
                                var id = record.get(‘id‘);
                                aarray.push(id.toString());
                                console.log(id.toString());
                            });
                        
                            
                            Ext.Ajax.request({
                                url:‘deleteAll.do‘,
//join()函数将
// 数组元素组合成长字符串ids传到后台 params:{ids:aarray.join(
",")}, method:‘POST‘, timeout:2000, success:function(response,opts){ // Ext.Array.each(data,function(record){ // st.remove(record); // }) Ext.Msg.alert("删除操作","操作成功"); var pagingObj = Ext.getCmp(‘ptb‘); pagingObj.doRefresh(); } }); } } },

后端代码

@RequestMapping(value="/deleteAll",method=RequestMethod.POST)
    public void deleteAllIndustry(HttpServletRequest request,HttpServletResponse response){
        String ids = request.getParameter("ids");
        System.out.println(ids+"!!!!!!!!!!"+"deleteAll control层");
        String[] tokens = ids.split(",");
        
        for(String s : tokens){
            int p_key = Integer.valueOf(s);
            industryService.deleteIndustryById(p_key);
        }
        String msg = "{success : true}";
        try {
            response.getWriter().write(msg);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

 

json格式实现批量删除

标签:style   blog   http   color   os   io   for   ar   div   

原文地址:http://www.cnblogs.com/hzmbbbb/p/3936573.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!