當(dāng)幸福來(lái)敲門

          我就會(huì)牢牢抓住!
          隨筆 - 50, 文章 - 3, 評(píng)論 - 8, 引用 - 0
          數(shù)據(jù)加載中……

          jquery目錄樹 js實(shí)現(xiàn) 目錄數(shù)插件

          2011-07-13 10:07

          jQuery 目錄樹插件介紹——ligerTree

           

           

          一,簡(jiǎn)介 

          ligerTree的功能列表:

          1,支持本地?cái)?shù)據(jù)和服務(wù)器數(shù)據(jù)(配置data或者url)

          2,支持原生html生成Tree

          3,支持動(dòng)態(tài)獲取增加/修改/刪除節(jié)點(diǎn)

          4,支持大部分常見的事件

          5,支持獲取選中行等常見的接口方法

           

          二,第一個(gè)例子

          引入庫(kù)文件

          遵循LigerUI系列插件的設(shè)計(jì)原則(插件盡量單獨(dú)),ligerTree是一個(gè)單獨(dú)的插件,也就是說(shuō)只需要引入plugins/ligerTree.js和樣式css文件就可以使用(當(dāng)然必須先引入jQuery),在這個(gè)例子中,我把tree用到的樣式和圖片分離了出來(lái),有興趣的朋友可以下載來(lái)看看

            

          <script src="lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
          <link href="lib/ligerUI/skins/Aqua/css/ligerui-tree.css" rel="stylesheet" type="text/css"/>
          <script src="lib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>

          加入HTML

            

          <ul id="tree1">
          <li>
          <span>節(jié)點(diǎn)1</span>
          <ul>
          <li>
          <span>節(jié)點(diǎn)1.1</span>
          <ul>
          <li><span>節(jié)點(diǎn)1.1.1</span></li>
          <li><span>節(jié)點(diǎn)1.1.2</span></li>
          </ul>
          </li>
          <li><span>節(jié)點(diǎn)1.2</span></li>
          </ul>
          </li>
          </ul>

          調(diào)用ligerTree

          <table style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: normal !important; font-style: normal !important; font-size: 1em !important; min-height: inherit !important; border-collapse: collapse !important; background-position: initial initial !important; background-repeat: initial initial !important; "><td style="font-size: 1em !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: initial !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: top !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: normal !important; font-style: normal !important; min-height: inherit !important; border-left-style: none !important; border-left-color: initial !important; color: rgb(0, 0, 0) !important; background-position: initial initial !important; background-repeat: initial initial !important; ">$("#tree1").ligerTree();

          效果圖

          三,常用場(chǎng)景

          場(chǎng)景一:不使用復(fù)選框: 

          $("#tree2").ligerTree({ checkbox: false });

          場(chǎng)景二:不使用復(fù)習(xí)框和圖標(biāo): 

          $("#tree3").ligerTree({ checkbox: false, parentIcon: null, childIcon: null });

          效果如圖:

          ?

          append(parentNode, newdata)增加節(jié)點(diǎn)集合clear()清空collapseAll()全部節(jié)點(diǎn)都折疊demotion(treenode)降級(jí)為葉節(jié)點(diǎn)級(jí)別expandAll()全部節(jié)點(diǎn)都展開getChecked()獲取選擇的行(復(fù)選框)getData()獲取樹的數(shù)據(jù)源getParentTreeItem(treenode, level)獲取父節(jié)點(diǎn)getSelected()獲取選擇的行hasChildren(treenode)是否包含子節(jié)點(diǎn) loadData(node, url, param)加載數(shù)據(jù)remove(node)刪除節(jié)點(diǎn)upgrade(treenode)升級(jí)為父節(jié)點(diǎn)級(jí)別

          posted on 2012-07-04 16:59 wyx 閱讀(2096) 評(píng)論(1)  編輯  收藏

          評(píng)論

          # re: jquery目錄樹 js實(shí)現(xiàn) 目錄數(shù)插件  回復(fù)  更多評(píng)論   

          11
          2015-03-24 20:27 | 11

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 邳州市| 光山县| 晋城| 菏泽市| 拜泉县| 和田市| 武功县| 克东县| 科技| 中宁县| 衡东县| 武胜县| 柘荣县| 依兰县| 合水县| 兴海县| 获嘉县| 玛多县| 安泽县| 龙州县| 侯马市| 海宁市| 江川县| 丰镇市| 闽清县| 施秉县| 东至县| 崇左市| 贵定县| 神木县| 凤山市| 大厂| 曲阳县| 定州市| 黄梅县| 吉水县| 永顺县| 丰县| 南木林县| 怀仁县| 册亨县|