一、EasyUI創建基礎樹形網格
樹形網格(TreeGrid)組件從數據網格(DataGrid)繼承,但是允許在行之間存在父/子節點關系。許多屬性繼承至數據網格(DataGrid),可以用在樹形網格(TreeGrid)中。為了使用樹形網格(TreeGrid),用戶必須定義 'treeField' 屬性,指明哪個字段作為樹節點。
本文將向您展示如何使用樹形網格(TreeGrid)組件設置一個文件夾瀏覽。
創建樹形網格(TreeGrid)
<table id="test" title="Folder Browser" class="easyui-treegrid" style="width:400px;height:300px" url="data/treegrid_data.json" rownumbers="true" idField="id" treeField="name"> <thead> <tr> <th field="name" width="160">Name</th> <th field="size" width="60" align="right">Size</th> <th field="date" width="100">Modified Date</th> </tr> </thead> </table>
二、EasyUI創建復雜樹形網格
樹形網格(TreeGrid)可以展示有限空間上帶有多列和復雜數據電子表格。本教程將演示如何將表格數據排列在分割的網格和多行表頭中,以便組織共同的數據。
創建樹形網格(TreeGrid)
<table title="Complex TreeGrid" class="easyui-treegrid" style="width:550px;height:250px" url="data/treegrid2_data.json" rownumbers="true" showFooter="true" idField="id" treeField="region"> <thead frozen="true"> <tr> <th field="region" width="150">Region</th> </tr> </thead> <thead> <tr> <th colspan="4">2009</th> <th colspan="4">2010</th> </tr> <tr> <th field="f1" width="50" align="right">1st qrt.</th> <th field="f2" width="50" align="right">2st qrt.</th> <th field="f3" width="50" align="right">3st qrt.</th> <th field="f4" width="50" align="right">4st qrt.</th> <th field="f5" width="50" align="right">1st qrt.</th> <th field="f6" width="50" align="right">2st qrt.</th> <th field="f7" width="50" align="right">3st qrt.</th> <th field="f8" width="50" align="right">4st qrt.</th> </tr> </thead> </table>
正如您所看到的,樹形網格(Treegrid)的使用和數據網格(Datagrid)一樣。請使用 'frozen' 屬性來定義凍結列,列的 'colspan' 和 'rowspan' 屬性來定義多行表頭。
以上就是分別為大家分享的EasyUI創建簡單樹形網絡和復雜樹形網絡的方法,希望對大家的學習有所幫助。
想要學習更多內容請查看這篇文章: 《輕松學習jQuery插件EasyUI EasyUI實現樹形網絡基本操作(2)》