其中提供了一種從后臺取數據渲染成樹的形式: 復制代碼 代碼如下: $("#mytree").tree({ data : { type : "json", url : "${ctx}/user/power!list.do" } }); 對于url中返回的 " /> 1000视频在线播放,毛片网站视频,纵欲(高H)

天天躁日日躁狠狠躁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數據的轉換代碼,轉載需保留來源!

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

主站蜘蛛池模板: 全免费午夜一级毛片 | 欧洲美女高清一级毛片 | 父亲在线日本综艺免费观看全集 | 洗濯屋H纯肉动漫在线观看 羲义嫁密着中出交尾gvg794 | 亚洲视频成人 | 伦理片在线线看手机版 | 日本漫画母亲口工子全彩 | 99re久久超碰视频精品 | 国产剧情福利AV一区二区 | 亚洲国产精品无码2019 | 国产精品久人妻精品 | 欧洲另类一二三四区 | 亚洲国产欧美日本大妈 | 韩国精品无码少妇在线观看网站 | 亚洲精品不卡在线 | 中文人妻熟妇精品乱又伦 | 欧美日韩国产高清综合二区 | 中文字幕亚洲乱码熟女在线 | 黄色三级视频在线观看 | 久久草这里全是精品香蕉频线观 | 亚洲免费视频观看 | 野花高清在线观看免费3中文 | 渔夫床满艳史bd高清在线直播 | 国产色精品久久人妻无码看片 | 9277在线观看资源 | 99精品免费久久久久久久久日本 | 欧美午夜a级精美理论片 | 男人J桶进男人屁股过程 | 97人妻丰满熟妇AV无码 | 拔萝卜电视剧高清免费 | 日韩内射美女人妻一区二区三区 | 国产精品久久久久久久人热 | 免费A级毛片无码无遮挡内射 | 日韩一区二区三区精品 | 老版香蕉版下载 | 97人人添人人澡人人澡人人澡 | 成年人视频在线免费观看 | 杨幂视频1分11未删减在线观看 | 国产午夜在线精品三级a午夜电影 | 免费在线看视频 | 亚洲天堂一区二区三区 |