zoukankan      html  css  js  c++  java
  • json格式实现批量删除

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

     '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();
            }
        }
  • 相关阅读:
    Oracle数据库安装
    [转]卡西欧手表调日期正确方法
    python密码处理(可用于生产模式)
    [转]python对json的相关操作
    [转]Python中的with…as…
    Python标准库--os模块
    我的github代码添加
    Python正则表达式+自创口诀
    自己总结python用xlrdxlwt读写excel
    CentOS安装+配置+远程
  • 原文地址:https://www.cnblogs.com/hzmbbbb/p/3936573.html
Copyright © 2011-2022 走看看