遍历后台的List,让前台的多选宽被选中
后端代码:
/** * 获取优惠卷分页信息 * * * @param ph * 包括查询条件以及分页查询条件 * */ @Override public DataGrid<AppCmsCouponsModel> selectCouponsPage(PageHelper ph) { Map<String, Object> param = new HashMap<String, Object>(); DataGrid<AppCmsCouponsModel> appQlUserData = new DataGrid<AppCmsCouponsModel>(); param.put("page", (ph.getPage() - 1) * ph.getRows()); param.put("rows", ph.getRows()); param.put("title", ph.getSearch()); List<AppCmsCouponsModel> appCmsCouponsModelList = AppCmsCouponsExMapper.selectAllCoupons(param);// 获取对应的优惠卷信息列表 for (AppCmsCouponsModel model : appCmsCouponsModelList) {// 遍历 // 通过优惠卷id,获取中间表列表 List<QlCmsApplicationCoupons> list = qlCmsApplicationCouponsExMapper.selectCouponsAndAPP(model.getId()); if (list != null && list.size() > 0) { // 通过中间表,批量获取app对象列表 List<AppCmsApplicationModel> appList = appCmsApplicationExMapper.getApplicationByCouponsIds(list); model.setAppList(appList); } } long total = AppCmsCouponsExMapper.selectCouponsCount(param);// 获取优惠卷总数量 appQlUserData.setRows(appCmsCouponsModelList); appQlUserData.setTotal(total); System.out.println(JSONObject.fromObject(appQlUserData)); return appQlUserData; }
然后输出的JSON是这样的
row.address可以取出22222,appList是数组,里面又有对象
for(var i in row.appList){
var id="#app"+row.appList[i].id;
$C.$.modalDialog.handler.find(id).attr('checked','true');
}
row.appList[i].id就可以拿到78了