zesen2008 发表于 2013-11-29 23:30:43

树形dgCol列怎么引用TreeGrid.attributes中的值

请高手指点
页面代码:
<t:datagrid name="venGoodsSortList" title="商器类型" actionUrl="venGoodsSortController.do?datatreegrid" idField="id" treegrid="true" pagination="false" fit="true">
....
   <t:dgCol title="拼音编码" field="gsSpell" treefield="attributes.get('gsSpell')" width="80"></t:dgCol>
....

后台代码:
@RequestMapping(params = "datatreegrid")
@ResponseBody
public List<TreeGrid> datatreegrid(HttpServletRequest request, TreeGrid treegrid) {
CriteriaQuery cq = new CriteriaQuery(VenGoodsSortEntity.class);
if(treegrid.getId() == null)
   cq.add(Restrictions.isNull("gsParentSort.id"));
else
   cq.add(Restrictions.eq("gsParentSort.id", treegrid.getId()));
List<VenGoodsSortEntity> goodSortList = venGoodsSortService.getListByCriteriaQuery(cq, false);
List<TreeGrid> treeGrids = new ArrayList<TreeGrid>();
for(VenGoodsSortEntity goodSort: goodSortList) {
   TreeGrid tg = new TreeGrid();
   tg.setId(goodSort.getId());
   if(goodSort.getGsParentSort() == null) {
    tg.setParentId(null);
    tg.setParentText("");
   }
   else {
    tg.setParentId(goodSort.getGsParentSort().getId());
    tg.setParentText(goodSort.getGsParentSort().getGsName());   
   }
   tg.setCode(goodSort.getGsCode());
   tg.setText(goodSort.getGsName());
   Map<String, String> map = new HashMap<String, String>();
   tg.setAttributes(map);
   map.put("gsSpell", goodSort.getGsSpell());
   
   tg.setState("closed");
   treeGrids.add(tg);
}
return treeGrids;
}

Nemo 发表于 2014-7-12 10:17:40

我也遇到这么问题,本来想用formatter来解决的,
页: [1]
查看完整版本: 树形dgCol列怎么引用TreeGrid.attributes中的值