其中提供了一種從后臺(tái)取數(shù)據(jù)渲染成樹(shù)的形式: 復(fù)制代碼 代碼如下: $("#mytree").tree({ data : { type : "json", url : "${ctx}/user/power!list.do" } }); 對(duì)于url中返回的 " /> 999久久久无码国产精蜜柚,aaa级黄影片,欧美 亚洲 中文字幕 高清

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

基于jsTree的無(wú)限級(jí)樹(shù)JSON數(shù)據(jù)的轉(zhuǎn)換代碼

jstree 主頁(yè) :
http://www.jstree.com/

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

對(duì)于url中返回的值必須是它定義的json數(shù)據(jù)形式:
復(fù)制代碼 代碼如下:
$("#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" }
]
}
});

這里需要一個(gè)從后臺(tái)實(shí)例集合轉(zhuǎn)換為它規(guī)定的json數(shù)據(jù)的形式.
復(fù)制代碼 代碼如下:
/** *//**
* 無(wú)限遞歸獲得jsTree的json字串
*
* @param parentId
* 父權(quán)限id
* @return
*/
private String getJson(long parentId)
{
// 把頂層的查出來(lái)
List<Action> actions = actionManager.queryByParentId(parentId);
for (int i = 0; i < actions.size(); i++)
{
Action a = actions.get(i);
// 有子節(jié)點(diǎn)
if (a.getIshaschild() == 1)
{
str += "{attributes:{id:/"" + a.getAnid()
+ "/"},state:/"open/",data:/"" + a.getAnname() + "/" ,";
str += "children:[";
// 查出它的子節(jié)點(diǎn)
List<Action> list = actionManager.queryByParentId(a.getAnid());
// 遍歷它的子節(jié)點(diǎn)
for (int j = 0; j < list.size(); j++)
{
Action ac = list.get(j);
//還有子節(jié)點(diǎn)(遞歸調(diào)用)
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;
}

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

其中Action是菜單類或權(quán)限類等的實(shí)體。
效果圖:

JavaScript技術(shù)基于jsTree的無(wú)限級(jí)樹(shù)JSON數(shù)據(jù)的轉(zhuǎn)換代碼,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产电影无码午夜在线播放 | 东京热 百度影音 | 捆绑白丝粉色JK震动捧喷白浆 | 香蕉久久av一区二区三区 | 国产精品AV无码免费播放 | 国产AV国片精品无套内谢无码 | 手机在线观看无码日韩视频 | 91情国产l精品国产亚洲区 | 久青草国产观看在线视频 | 久久99亚洲AV无码四区碰碰 | adc影院在线 | 精品国产福利在线视频 | 草神被爆漫画羞羞漫画 | 欧美性情video sexo视频 | 少妇邻居内射在线 | 免费国产在线观看 | 做i爱视频30分钟免费 | 人曽交Z00Z0OA片 | 国产永久免费高清在线观看 | 国产亚洲一区在线 | yellow免费| 亚洲免费每日在线观看 | 精品亚洲国产熟女福利自在线 | 中文字幕偷乱免费视频在线 | 青苹果乐园在线观看电视剧 | 国产精品乱人无码伦AV在线A | 午夜在线播放免费人成无 | 国产精亚洲视频综合区 | 亚洲嫩草影院久久精品 | 毛片在线播放网址 | 老头扒开粉缝亲我下面 | 大香网伊人久久综合网2020 | 伦理片92伦理午夜 | 久久爱狠狠综合网 | 日本漫画大全无翼乌 | adc年龄确认大驾光临入口 | 无码国产欧美日韩精品 | 四虎永久精品视频在线 | 99国产热视频在线观看 | 老司机福利视频一区在线播放 | 全彩无翼污之邪恶女教师 |