jQuery MiniUI
标题:
treegrid 从URL加载数据 和setData出现的结果不一样
[打印本页]
作者:
303974838
时间:
2014-8-11 09:53:48
标题:
treegrid 从URL加载数据 和setData出现的结果不一样
本帖最后由 303974838 于 2014-8-11 09:55 编辑
<div id="treegrid" class="mini-treegrid" style="width: 100%; height: auto;"
url="/BusinessManagement.Web/Servs/AgreementRegionalDetailServ.ashx?Method=gettreeData&AgreementId=A3780108-F040-415F-A82E-B2678D8D7DB1"
treecolumn="name" idfield="id" parentfield="pid" resultastree="false"
allowresize="true" expandonload="true" showtreeicon="true"
allowselect="false" allowcellselect="false" enablehottrack="false"
allowcellwrap="true" showcheckbox="false" checkrecursive="true">
<div property="columns">
<div type="indexcolumn"></div>
<div name="name" field="name" width="150">省/市</div>
<div field="treeDatas" width="100%">区县</div>
</div>
</div>
如果这样的代码, 显示正常
下面的JSON 是我直接请求,拿到的数据 一模一样的
如果改成
<div id="treegrid" class="mini-treegrid" style="width: 100%; height: auto;"
treecolumn="name" idfield="id" parentfield="pid" resultastree="false"
allowresize="true" expandonload="true" showtreeicon="true"
allowselect="false" allowcellselect="false" enablehottrack="false"
allowcellwrap="true" showcheckbox="false" checkrecursive="true">
<div property="columns">
<div type="indexcolumn"></div>
<div name="name" field="name" width="150">省/市</div>
<div field="treeDatas" width="100%">区县</div>
</div>
</div>
var jsonData = [
{
"id": "959a1fb0-4eea-4372-8c40-24c1cfd67f74",
"name": "广东",
"pid": "00000000-0000-0000-0000-000000000000",
"treeDatas": null,
"check": false
},
{
"id": "91e988e4-8d04-4aa6-97ef-d0bbde9e006d",
"name": "汕头市",
"pid": "959a1fb0-4eea-4372-8c40-24c1cfd67f74",
"treeDatas": [
{
"id": "956cae22-de10-4035-a572-dc9ac3e60f5c",
"name": "龙湖区",
"pid": "91e988e4-8d04-4aa6-97ef-d0bbde9e006d",
"treeDatas": null,
"check": false
}
],
"check": false
},
{
"id": "5885a7f4-0895-423e-8d05-f5436e70a74b",
"name": "珠海市",
"pid": "959a1fb0-4eea-4372-8c40-24c1cfd67f74",
"treeDatas": [
{
"id": "2236cb52-5516-4994-a6cc-7dbe766cbbfb",
"name": "斗门区",
"pid": "5885a7f4-0895-423e-8d05-f5436e70a74b",
"treeDatas": null,
"check": false
},
{
"id": "a7a35233-6174-4614-a534-6fa2a75b9a5b",
"name": "金湾区",
"pid": "5885a7f4-0895-423e-8d05-f5436e70a74b",
"treeDatas": null,
"check": false
},
{
"id": "154b2af4-c557-4509-88a1-6d31696d6c1c",
"name": "香洲区",
"pid": "5885a7f4-0895-423e-8d05-f5436e70a74b",
"treeDatas": null,
"check": false
}
],
"check": false
},
{
"id": "78f81311-4fb6-4485-84dc-542db8cbd9d0",
"name": "深圳市",
"pid": "959a1fb0-4eea-4372-8c40-24c1cfd67f74",
"treeDatas": [
{
"id": "64e0880c-5845-4289-afe1-17c21a07ddf9",
"name": "光明新区",
"pid": "78f81311-4fb6-4485-84dc-542db8cbd9d0",
"treeDatas": null,
"check": false
}
],
"check": false
}
];
$(function () {tree.setData(jsonData);}
这样写 显示 出现问题,,没有层次了。。。
求大神指点
作者:
felt
时间:
2014-8-11 09:57:22
url加载通过resultAsTree指定你返回数据的格式
静态数据加载
树形数据用loadData(data)
列表数据用loadList(data,id,pid)
你贴出来的url加载的resultAsTree是false的,你的数据不是树形
用loadList(data,id,pid)加载
作者:
303974838
时间:
2014-8-11 10:21:17
felt 发表于 2014-8-11 09:57
url加载通过resultAsTree指定你返回数据的格式
静态数据加载
树形数据用loadData(data)
谢谢版主 搞定了
欢迎光临 jQuery MiniUI (http://miniui.com/discuss/)
Powered by Discuz! X2