首页新闻找找看学习计划

EasyUI 中treegrid 为什么没数据

0
悬赏园豆:30 [已解决问题] 解决于 2014-12-15 10:57
{"total":3,"rows": [{"id":"4060d01f-c6a1-4b8e-9b03-a2904d4cfebe","ym00402":"4060d01f-c6a1-4b8e-9b03-a2904d4cfebe","ym00403":"","ym00404":"","ym00405":1.0000,"ym00406":0.00,"ym00408":"","ym00410":0.00,"ym00411":0.00,"bs00202":"SPZL000015","bs00203":"W=2A(2x+4y)+3B(x+3y)","bs00205":"","bs00102":"测试组","st00102":""},{"id":"4060d01f-c6a1-4b8e-9b03-a2904d4cfebe","ym00402":"4060d01f-c6a1-4b8e-9b03-a2904d4cfebe","ym00403":"14641b19-3f25-4545-b528-f69a6af66d06","ym00404":"c3dec451-43db-4117-a4bb-2124fcb77c52","ym00405":2.000000,"ym00406":"","ym00408":"","ym00410":0.000000,"ym00411":0.000000,"bs00202":"SPZL000016","bs00203":"A=2x+4y","bs00205":"","bs00102":"测试组","st00102":"","_parentId":"4060d01f-c6a1-4b8e-9b03-a2904d4cfebe"},{"id":"4060d01f-c6a1-4b8e-9b03-a2904d4cfebe","ym00402":"4060d01f-c6a1-4b8e-9b03-a2904d4cfebe","ym00403":"8ebdb859-93bb-4394-aee1-81cdbbc337c6","ym00404":"c3dec451-43db-4117-a4bb-2124fcb77c52","ym00405":3.000000,"ym00406":"","ym00408":"","ym00410":0.000000,"ym00411":0.000000,"bs00202":"SPZL000017","bs00203":"B=x+3y","bs00205":"","bs00102":"测试组","st00102":"","_parentId":"4060d01f-c6a1-4b8e-9b03-a2904d4cfebe"}]}

json 数据也是正常的,有_parentId,也有根节点。

$('#test').treegrid({
                title:'详情',
                iconCls:'icon-save',
                width:700,
                height:350,
                nowrap: false,
                rownumbers: true,
                animate:true,
                collapsible:true,
                url:"/OtherHtml/handler/02503/content.ashx?keyId="+keyId+"",
                idField:'id',
                treeField:'ym00402',
                frozenColumns:[[
                    {title:'编号',field:'ym00402',width:200,
                        formatter:function(value){
                            return '<span style="color:red">'+value+'</span>';
                        }
                    }
                ]],
                columns:[[
                  
                    {field:'bs00203',title:'商品名称',width:150},
                    {field:'bs00102',title:'商品类别',width:220,rowspan:2},
                    {field:'st00102',title:'计量单位',width:150,rowspan:2},
                    {field:'ym00405',title:'数量',width:150,rowspan:2},
                    {field:'bs00205',title:'规格',width:150,rowspan:2},
                    {field:'ym00410',title:'单价',width:150,rowspan:2},
                    {field:'ym00411',title:'金额',width:150,rowspan:2},
                    {field:'ym00406',title:'损耗',width:150,rowspan:2},
                    {field:'ym00408',title:'备注',width:150,rowspan:2}
                ]]
      })
为什么没数据
问题补充:

无力吐槽了,尼玛 这是回事,我在easyui官方网站上下载的demo,demo 里面包含的jq和easyui 2个版本居然有问题。下了个最新版本什么问题都没有

亦有哭亦有笑的主页 亦有哭亦有笑 | 初学一级 | 园豆:5
提问于:2014-08-20 12:18
< >
分享
最佳答案
0

jq和easyui 版本问题

亦有哭亦有笑 | 初学一级 |园豆:5 | 2014-08-20 16:13
其他回答(4)
0

后台访问数据库用的是什么?

LINQ to Sql还是EF还是ADO.net

收获园豆:6
骑着蜗牛耍流氓 | 园豆:178 (初学一级) | 2014-08-20 13:23

ADO.net,返回来的json 应该是没问题的

支持(0) 反对(0) 亦有哭亦有笑 | 园豆:5 (初学一级) | 2014-08-20 13:30

@亦有哭亦有笑: 

我也遇到过这样的问题,

json数据没问题,后台调试也没问题,但是前台就是数据不显示,最后我自己手动创建了一些实体类,然后在后台装箱拆箱,前台数据展示的是我实体类的类型,然后数据就出来了。

因为我用的是EF,同事说这是EF自动创建的实体类类型有问题,必须要自己再创建实体类,

不知道你那是不是和我以前一样的情况

支持(0) 反对(0) 骑着蜗牛耍流氓 | 园豆:178 (初学一级) | 2014-08-20 13:39
0

看了下你的数据,发现你的数据可能有问题。id和_parentId一致,这个应该不对,而且,第一条数据没有_parentId

收获园豆:6
幻天芒 | 园豆:36522 (高人七级) | 2014-08-20 13:37

第一条数据 是根节点,是没有_parentId,他去子节点格式不一样。另外,我将id和_parentId都改为int类型,还是没结果

支持(0) 反对(0) 亦有哭亦有笑 | 园豆:5 (初学一级) | 2014-08-20 14:03

@亦有哭亦有笑: 把你的新的数据贴出来看下?我觉得可以去官方demo上拿数据格式下来,然后套上你自己的数据。

支持(0) 反对(0) 幻天芒 | 园豆:36522 (高人七级) | 2014-08-20 14:46
0

给个思路解决问题:

1、easyui的官方示例代码中有关于treegrid的示例,将原有的json数据改为你问题中贴的json数据,看是否能出来treegrid

2、若没有出来证明不是你js生成treegrid的问题,是你生成的json数据有问题,检查你的url请求的地址,重新组织json(个人感觉这个问题概率大)

3、若是出来了,就麻烦了,应该是你的js生成treegrid的问题,对照示例程序,看看是不是有属性设置不合适

收获园豆:12
limiracle | 园豆:221 (菜鸟二级) | 2014-08-20 14:01

我将treegrid 改为原始的datatgrid 正常显示

支持(0) 反对(0) 亦有哭亦有笑 | 园豆:5 (初学一级) | 2014-08-20 14:27
0

json数据的最外层去掉。。只留json数组看看

收获园豆:6
龙卷风摧毁停车场! | 园豆:10 (初学一级) | 2014-08-20 14:08

去掉最外层的话,子节点没有包含在根节点下面,

根节点的json数据,没有_parentId

bs00102: "第一类"
bs00202: "SPZL000001"
bs00203: "自行车"
bs00205: "山地自行车"
id: 1

子节点

_parentId: 1
bs00102: "第一类"
bs00202: "SPZL000002"
bs00203: "车轮胎"
bs00205: "山地轮胎"
id: 2

 

支持(0) 反对(0) 亦有哭亦有笑 | 园豆:5 (初学一级) | 2014-08-20 14:40

@亦有哭亦有笑: 看错了 以为是datagrid...  

你设置的主键 idField:'id',但是你最外层没有id这个字段呀。。?

编号就是id (1,2,3)就是id啊,设置在第一列还是一样

支持(0) 反对(0) 亦有哭亦有笑 | 园豆:5 (初学一级) | 2014-08-20 15:09

@亦有哭亦有笑: 你的数据源是不是这个

{"total":3,"rows": [{"id":"4060d01f-c6a1-4b8e-9b03-a2904d4cfebe","ym00402":"4060d01f-c6a1-4b8e-9b03-a2904d4cfebe","ym00403":"","ym00404":"","ym00405":1.0000,"ym00406":0.00,"ym00408":"","ym00410":0.00,"ym00411":0.00,"bs00202":"SPZL000015","bs00203":"W=2A(2x+4y)+3B(x+3y)","bs00205":"","bs00102":"测试组","st00102":"个"}]}?

是的话 根节点哪里有id 了 ,,?

@咦?: 

{"total":4,"rows": [{"Id":1,"ym00402":"b32300e4-e647-4e48-944a-62e959142507","ym00403":"","ym00404":"","ym00405":1.0000,"ym00406":0.00,"ym00408":"","ym00410":0.00,"ym00411":0.00,"bs00202":"A2","bs00203":"2-A","bs00205":"","bs00102":"多层测试","st00102":"","ym00301":"0","_parentId":""},{"Id":2,"ym00402":"b32300e4-e647-4e48-944a-62e959142507","ym00403":"0ddc9fb5-7423-43e4-afe8-85d2d34d0684","ym00404":"c3dec451-43db-4117-a4bb-2124fcb77c52","ym00405":2.000000,"ym00406":"","ym00408":"","ym00410":0.000000,"ym00411":0.000000,"bs00202":"C3","bs00203":"3-C","bs00205":"","bs00102":"多层测试","st00102":"","ym00301":"","_parentId":1},{"Id":3,"ym00402":"b32300e4-e647-4e48-944a-62e959142507","ym00403":"faf8af33-031e-4166-b377-b520388601f5","ym00404":"c3dec451-43db-4117-a4bb-2124fcb77c52","ym00405":1.000000,"ym00406":"","ym00408":"","ym00410":0.000000,"ym00411":0.000000,"bs00202":"B3","bs00203":"3-B","bs00205":"","bs00102":"多层测试","st00102":"","ym00301":"","_parentId":1},{"Id":4,"ym00402":"b32300e4-e647-4e48-944a-62e959142507","ym00403":"f27d6129-2557-4b94-ad60-d26e55aaa331","ym00404":"c3dec451-43db-4117-a4bb-2124fcb77c52","ym00405":1.000000,"ym00406":"","ym00408":"","ym00410":0.000000,"ym00411":0.000000,"bs00202":"A3","bs00203":"3-A","bs00205":"","bs00102":"多层测试","st00102":"","ym00301":"","_parentId":1}],"footer":[{"bs00202":"sss"}]}

这和官方给的demo中的json数据结构一样,但是不显示。去掉外层的total和rows的话,显示但不分层

支持(0) 反对(0) 亦有哭亦有笑 | 园豆:5 (初学一级) | 2014-08-20 15:47

@亦有哭亦有笑: 不清楚。。可能版本不一样吧。。你先把你补充问题说的那个错误解决掉吧。打断点调试看看。 undefined is not a function 是执行了某个未赋值的函数变量

清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册