Easyui Tree扁平化数据不显示父节点的一种解决方法
生活随笔
收集整理的這篇文章主要介紹了
Easyui Tree扁平化数据不显示父节点的一种解决方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用SSM框架結合Easyui搭建一個簡單CRUD表單時遇到無法設置父節點的問題,輸出如下:
后臺controller代碼:
1 public List<Tree> queryname(){ 2 List<Tree> list = treeService.queryname(); 3 return list;前臺獲得的list:
[{"id": 1, "name": "區人大黨組"},{"id": 2, "name": "區政府"},{"id": 5, "_parentId": 1, "name": "區人大2"},{"id": 7, "_parentId": 2, "name": "區政府2"},{"id": 22, "name": "機關"},{"id": 23, "name": "機關"},{"id": 31, "_parentId": 22, "name": "機關伙房"}]對比Easyui官方實例提供的JSON數據格式進行對比:
{"rows":[{"id":1,"name":"All Tasks","progress":60,"iconCls":"icon-ok"},{"id":2,"name":"Designing","progress":100,"_parentId":1,"state":"closed"},{"id":21,"name":"Database","persons":2,"progress":100,"_parentId":2},{"id":22,"name":"UML","persons":1,"progress":100,"_parentId":2},{"id":23,"name":"Export Document","persons":1,"progress":100,"_parentId":2},{"id":3,"name":"Coding","persons":2,"progress":80},{"id":4,"name":"Testing","persons":1,"progress":20}]}發現后臺返回的List的確是JSON格式,但缺少了一個"rows":
要檢測數據是否為JSON格式可以使用以下工具校驗:https://www.bejson.com/
解決方法如下:
controller修改為:
1 public Map<String, List<Tree>> queryname(){ 2 List<Tree> list = treeService.queryname(); 3 Map<String, List<Tree>> map = new HashMap<String, List<Tree>>(); 4 map.put("rows", list); 5 return map;成功!
?
轉載于:https://www.cnblogs.com/zhagzicheg/p/9166933.html
總結
以上是生活随笔為你收集整理的Easyui Tree扁平化数据不显示父节点的一种解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DCI模型架构
- 下一篇: 在ThinkAdmin中增加显示数据表格