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(); } }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。