其中提供了一種從后臺取數據渲染成樹的形式: 復制代碼 代碼如下: $("#mytree").tree({ data : { type : "json", url : "${ctx}/user/power!list.do" } }); 對于url中返回的 " /> 九九久久久2,纲手胸被爆羞羞免费,MD传媒MD0021在线观看

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

基于jsTree的無限級樹JSON數據的轉換代碼

jstree 主頁 :
http://www.jstree.com/

其中提供了一種從后臺取數據渲染成樹的形式:
復制代碼 代碼如下:
$("#mytree").tree({
data : {
type : "json",
url : "${ctx}/user/power!list.do"
}
});

對于url中返回的值必須是它定義的json數據形式:
復制代碼 代碼如下:
$("#demo2").tree({
data : {
type : "json",
json : [
{ attributes: { id : "pjson_1" }, state: "open", data: "Root node 1", children : [
{ attributes: { id : "pjson_2" }, data: { title : "Custom icon", icon : "../media/images/ok.png" } },
{ attributes: { id : "pjson_3" }, data: "Child node 2" },
{ attributes: { id : "pjson_4" }, data: "Some other child node" }
]},
{ attributes: { id : "pjson_5" }, data: "Root node 2" }
]
}
});

這里需要一個從后臺實例集合轉換為它規定的json數據的形式.
復制代碼 代碼如下:
/** *//**
* 無限遞歸獲得jsTree的json字串
*
* @param parentId
* 父權限id
* @return
*/
private String getJson(long parentId)
{
// 把頂層的查出來
List<Action> actions = actionManager.queryByParentId(parentId);
for (int i = 0; i < actions.size(); i++)
{
Action a = actions.get(i);
// 有子節點
if (a.getIshaschild() == 1)
{
str += "{attributes:{id:/"" + a.getAnid()
+ "/"},state:/"open/",data:/"" + a.getAnname() + "/" ,";
str += "children:[";
// 查出它的子節點
List<Action> list = actionManager.queryByParentId(a.getAnid());
// 遍歷它的子節點
for (int j = 0; j < list.size(); j++)
{
Action ac = list.get(j);
//還有子節點(遞歸調用)
if (ac.getIshaschild() == 1)
{
this.getJson(ac.getParentid());
}
else
{

str += "{attributes:{id:/"" + ac.getAnid()
+ "/"},state:/"open/",data:/"" + ac.getAnname()
+ "/" " + " }";
if (j < list.size() - 1)
{
str += ",";
}
}
}
str += "]";
str += " }";
if (i < actions.size() - 1)
{
str += ",";
}
}
}
return str;
}

調用:
復制代碼 代碼如下:
@org.apache.struts2.convention.annotation.Action(results =
{ @Result(name = "success", location = "/main/user/action-list.jsp") })
public String list()
{
String str = "[";
// 從根開始
str += this.getJson(0);
str += "]";
this.renderJson(str);
return null;
}

其中Action是菜單類或權限類等的實體。
效果圖:

JavaScript技術基于jsTree的無限級樹JSON數據的轉換代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 久久这里只有精品视频e | free性中国hd护士高清 | 日韩AV无码一区二区三区不卡毛片 | 亚洲AV无码乱码在线观看浪潮 | 中文字幕乱码一区久久麻豆樱花 | 一二三四在线视频社区 | 国产不卡一卡2卡三卡4卡网站 | 福利啪啪吧 | 俄罗斯爱爱| 国产欧美日韩中文视频在线 | 久久噜国产精品拍拍拍拍 | 国产成人在线小视频 | 人人干人人插 | 一级毛片全部免 | 87影院午夜福利 | 黄色三级在线观看 | 国产在线精品视频资源 | 成人a毛片久久免费播放 | 久久精品国产免费中文 | 丝袜足控免费网站xx91 | 蜜芽亚洲欧美一区二区电影 | 中文字幕在线观看 | 让人爽到湿的小黄书 | 国产成人a一在线观看 | 暖暖视频免费观看高清完整版 | 久久热精品18国产 | 青青青久草 | 精品久久久久中文字幕加勒比东京热 | 约艺术院校96年清纯白嫩 | 欧美激情性AAAAA片欧美 | 青青青青青青青草 | 日本人奶水中文影片 | 久久影院一区 | 九九在线中文字幕无码 | 在线观看qvod | wwwwxxxx欧美| 狠狠色丁香久久婷婷综合_中 | 丝袜情趣在线资源二区 | 免费人成视频X8X8国产更快乐 | 亚洲精品第一页 | 二级毛片免费观看全程 |