easyUI中onLoadSuccess方法获取多个对象


 

后台将一个list中的对象循环放到map中,如下:

    @RequestMapping("/getSaleOrderDetailList")
    @ResponseBody
    public Map<String,Object>  getSaleOrderDetailList(Model model,HttpServletRequest request,HttpServletResponse response)
    {

        ... ...
//新增时,复制订单 if(StringUtils.isNotBlank(copyId)){ SaleOrder copyOrder = saleOrderService.getById(copyId); if(copyOrder!=null){ List<SaleOrderDetail> copyList = saleOrderDetailService.getBySodNbr(copyOrder.getSoNbr()); resultMap.put("listCount", copyList.size());
          //这里循环将对象放到copyList+i中
for(int i=0;i<copyList.size();i++){ resultMap.put("copyList" + i,copyList.get(i)); } } } return resultMap; }

 

前台中获取对象,注意必须使用中括号将变量i和常量'copyList'放一起括括起来。

             onLoadSuccess:function(data){
     //加载完成后,判断是否是新建订单复制订单
                var num = data.listCount;
                if(num > 0){
                    for(var i=0;i<num;i++){                
                        alert(data['copyList'+i]);   //这种正确:必须使用中括号来获取
//                      alert(data.copyList+i);  这种写法是错误的,永远获取不到对象
                        copyOrder(data['copyList'+i]);
                    }
                }
            },

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM