easyUI的treeGrid数据格式


首先idField是要唯一,这个是肯定的


刚开始看api,以为父子节点是treeField定义,后来怎么改这个字段的数据都不出来,后来才知道json数据源中“_parentId”才是决定父子节点的关键,

意思就是说在子节点中加上“_parentId”字段,然后该字段对应的值是父节点的resourceId就行了,所以在

时隔一年,重新用到这个东西,发现一个问题,最顶级的节点的"_parentId"需要设为"",否则数据加载不到表格中

js代码:

<div data-options="region:'center'" style="border-width: 1px 1px 0px 0px;">
<table id="resourceTab" class="easyui-treegrid" title="项目标段"
data-options="border:false,rownumbers:true,fit:true,striped:true,idField:'resourceId',treeField:'name',onClickRow:clickRow,onDblClickRow:dbClickRow,onLoadSuccess: collapseAll,toolbar:'#tb',url:'${pageContext.request.contextPath}/xxxx/xxxxx.do'">
<thead data-options="frozen:true"> 
<tr>
<th data-options="field:'name',width:230,align:'left'">名称</th>
        </tr>
</thead>
<thead>
<tr>
<th data-options="field:'projCode',width:150,align:'center',formatter:formatCode">编号</th>
<th data-options="field:'startStack',width:120,align:'center'">起点桩号</th>
<th data-options="field:'endStack',width:120,align:'center'">终点桩号</th>
<th data-options="field:'startTime',width:120,align:'center'">开工日期</th>
<th data-options="field:'endTime',width:120,align:'center'">完工日期</th>
<th data-options="field:'isEnable',width:150,align:'center',formatter:formatIsEnable">是否启用</th>
</tr>
</thead>
</table>
</div>






控制层代码:

map为已经封装好的数据源,转成json字符串后替换一下就好

String jsonString = JSON.toJSONString(map);
jsonString = jsonString.replaceAll("\"parentId\"", "\"_parentId\""); // treegrid,父ID定义
printWriterStringToJson(response, jsonString);


效果图:



  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值