jquery中EasyUI實(shí)現(xiàn)異步樹
前臺使用EasyUI實(shí)現(xiàn) . EasyUI向后臺傳遞一個id參數(shù) .
第一次加載 , 向后臺傳遞的id為null .
之后每次將樹節(jié)點(diǎn)展開 , 會向后臺傳遞一個當(dāng)前節(jié)點(diǎn)的 id .
Control層 :
/**
* tree
*/
@RequestMapping(value = "/tree.do")
public void mytree(HttpServletResponse response, String id) {
this.writeJson(response, bookService.getChildrenTree(id));
}
Service層 :
@Transactional
@Override
public List<Tree> getChildrenTree(String pid) {
try {
List<Tree> result = new ArrayList<Tree>();
//獲得兒子節(jié)點(diǎn)的列表
List<TBookType> childrenList = this.getChildrenType(pid);
if (childrenList != null && childrenList.size() > 0) {
for (TBookType child : childrenList) {
// 獲取孫子的個數(shù)
long count = bookDao.getChildrenCount(String.valueOf(child.getId()));
Tree node = new Tree();
node.setId(String.valueOf(child.getId()));
node.setPid(String.valueOf(child.getPid()));
node.setText(child.getName());
node.setChildren(null);
node.setState(count > 0 ? "closed" : "open");
//將兒子列表childrenList數(shù)據(jù)逐個存到樹當(dāng)中
result.add(node);
}
}
return result;
} catch (Exception e) {
throw new BusinessException("獲取圖書類型數(shù)據(jù)出現(xiàn)錯誤!", e);
}
}
Dao層 :
@Override
public List<TBookType> getChildrenType(String pid) {
//這個的pid就是當(dāng)前展開節(jié)點(diǎn)的id , 通過父節(jié)點(diǎn)的 id 來獲得子節(jié)點(diǎn)
StringBuilder sqlstr = new StringBuilder();
if (StringUtils.isBlank(pid))
sqlstr.append("select * from booktype bt where bt.pid=0");
else
sqlstr.append("select * from booktype bt where bt.pid=" + pid );
return this.search2(TBookType.class, sqlstr.toString());
}
@Override
public long getChildrenCount(String pid) {
//這個的pid就是當(dāng)前展開節(jié)點(diǎn)的id , 通過父節(jié)點(diǎn)的 id 來獲得子節(jié)點(diǎn)的個數(shù)
StringBuilder sqlstr = new StringBuilder();
if (StringUtils.isBlank(pid))
sqlstr.append("select count(*) from booktype tb where tb.pid='0'");
else
sqlstr.append("select count(*) from booktype tb where tb.pid='" + pid + "'");
return this.count(sqlstr.toString());
}
以上所述就是本文關(guān)于EasyUI實(shí)現(xiàn)異步樹的全部代碼了,希望對大家能有所幫助
- 淺談EasyUi ComBotree樹修改 父節(jié)點(diǎn)選擇的問題
- EasyUi combotree 實(shí)現(xiàn)動態(tài)加載樹節(jié)點(diǎn)
- 輕松學(xué)習(xí)jQuery插件EasyUI EasyUI創(chuàng)建樹形菜單
- Jquery easyui 實(shí)現(xiàn)動態(tài)樹
- jquery中EasyUI實(shí)現(xiàn)同步樹
- EasyUI Tree+Asp.net實(shí)現(xiàn)權(quán)限樹或目錄樹導(dǎo)航的簡單實(shí)例
- jQuery EasyUI API 中文文檔 - TreeGrid 樹表格使用介紹
- EasyUI創(chuàng)建人員樹的實(shí)例代碼
相關(guān)文章
jQuery實(shí)現(xiàn)表單步驟流程導(dǎo)航代碼分享
這篇文章主要介紹了jQuery實(shí)現(xiàn)表單步驟流程導(dǎo)航,代碼實(shí)現(xiàn)效果簡單精致,推薦給大家,有需要的小伙伴可以參考下。2015-08-08jQuery實(shí)現(xiàn)圖片加載完成后改變圖片大小的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)圖片加載完成后改變圖片大小的方法,結(jié)合實(shí)例形式分析了jQuery圖片樣式與頁面元素屬性動態(tài)操作的相關(guān)技巧,需要的朋友可以參考下2016-03-03jquery獲取input type=text中的值的各種方式(總結(jié))
下面小編就為大家?guī)硪黄猨query獲取input type=text中的值的各種方式(總結(jié))。小編覺的挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-12-12jQuery中設(shè)置form表單中action值的實(shí)現(xiàn)方法
下面小編就為大家?guī)硪黄猨Query中設(shè)置form表單中action值的實(shí)現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05擴(kuò)展easyui.datagrid,添加數(shù)據(jù)loading遮罩效果代碼
easyui可以說是輕量級的前端UI框架,更新到1.2.1支持更多的事件,方法和屬性2010-11-11jQuery插件FusionCharts實(shí)現(xiàn)的2D面積圖效果示例【附demo源碼下載】
這篇文章主要介紹了jQuery插件FusionCharts實(shí)現(xiàn)的2D面積圖效果,結(jié)合完整實(shí)例形式分析了FusionCharts繪制2D面積圖的完整步驟與相關(guān)屬性設(shè)置操作技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2017-03-03jQuery獲取CSS樣式中的顏色值的問題,不同瀏覽器格式不同的解決辦法
jQuery獲取CSS樣式中的顏色值的問題,不同瀏覽器格式不同的解決辦法,需要的朋友可以參考一下2013-05-05