DIV CSS 佈局教程網

jQuery EasyUI Tree 樹狀元件使用指南
編輯:JQuery特效代碼     

Tree 是 jQuery EasyUI 中用來呈現層級結構的元件。它可以直接使用 ul 元素定義,也可以透過遠端 JSON 資料動態載入。

基本用法

若使用 ul 結構,只需將清單轉換為 tree 元件即可。若使用空容器,則可透過 url 指定資料來源,讓 Tree 自動載入節點。

資料格式

每個節點通常可包含 id、text、state、checked、attributes 與 children。其中 state 可設為 open 或 closed,用來表示節點是否展開。

常用特性

  • url:指定遠端資料來源。
  • method:設定請求方式。
  • animate:控制展開收合時是否顯示動畫。
  • checkbox:在節點前顯示核取方塊。
  • cascadeCheck:啟用級聯勾選。
  • onlyLeafCheck:只在葉節點顯示核取方塊。
  • dnd:啟用拖放功能。
  • data:載入本地節點資料。

事件

Tree 提供多種事件,例如 onClick、onDblClick、onBeforeLoad、onLoadSuccess、onLoadError、onBeforeExpand、onExpand、onBeforeCollapse、onCollapse、onCheck、onBeforeSelect、onSelect、onContextMenu、onDrop、onBeforeEdit、onAfterEdit 與 onCancelEdit。

方法

常用方法包含 loadData、getNode、getData、reload、getRoot、getRoots、getParent、getChildren、getChecked、getSelected、find、select、check、uncheck、collapse、expand、collapseAll、expandAll、expandTo、append、toggle、insert、remove、pop、update、enableDnd、disableDnd、beginEdit、endEdit 與 cancelEdit。

結語

Tree 適合處理分類、選單、檔案結構與層級資料。掌握節點資料格式與常用方法,就能快速建立互動式樹狀介面。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved