//jsp页面的标签=====>需要加载树的地方 <ul class="easyui-tree" id="tree" lines="true"></ul> //树 ===>jsp中的代码 $.ajax({ url: "TreeContrller/gettree",//需要调用的controller type: 'POST', data: {//需要那些参数你自己填 }, dataType: 'json', success: function (data) { var data2=data;//data是从controller中返回的数据 var treeData=[{//因为根节点就一个,所以这里写了死数据 "id":1, "text":"SysDomain", "state":"open", "iconCls":"icon-filter", "children":data2 }] $('#tree').tree({//获取标签加载树 data: treeData,//包装后树的数据 onClick: function (node) {//加载树后单击调用的事件 //alert(node.id); // 单击icon-search var id=node.id;//得到选种树节点的id document.getElementById("iframe").contentWindow.searchDepartmentAddressBook(id); //传id到子页面,调用子页面的searchDepartmentAddressBook(id)方法 //修改树的状态(展开/折叠) $(this).tree(node.state === 'closed' ? 'expand' : 'collapse', node.target); node.state = node.state === 'closed' ? 'open' : 'closed'; } }); } } ); //controller返回数据的样子
- [{
- "id":1, //id
- "text":"Folder1", //树的名称
- "iconCls":"icon-save", //树的图标
- "children":[{ //树 下的子节点
- "text":"File1",
- "checked":true
- },{
- "text":"Books",
- "state":"open",
- "attributes":{
- "url":"/demo/book/abc",
- "price":100
- },
- "children":[{
- "text":"PhotoShop",
- "checked":true
- },{
- "id": 8,
- "text":"Sub Bookds",
- "state":"closed"
- }]
- }]
- },{
- "text":"Languages",
- "state":"closed",
- "children":[{
- "text":"Java"
- },{
- "text":"C#"
- }]
- }]
03-05
139
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交