ExtJS4學習筆記十一 樹控件的使用

一、樹面板簡單示例 
Javascript代碼  收藏代碼
  1. var tree = Ext.create('Ext.tree.Panel', {  
  2.     title: '樹面板簡單示例',  
  3.     width : 150,  
  4.     height : 100,  
  5.     renderTo: Ext.getBody(),  
  6.     root: {  
  7.         text: '樹根',//節點名稱  
  8.         expanded: true,//默認展開根節點  
  9.         children: [{  
  10.             text: '節點一',//節點名稱  
  11.             leaf: true//true說明爲葉子節點  
  12.         }, {  
  13.             text: '節點二',//節點名稱  
  14.             leaf: true//true說明爲葉子節點  
  15.         }]  
  16.     }  
  17. });  


二、多列樹示例 
Javascript代碼  收藏代碼
  1. var tree = Ext.create('Ext.tree.Panel', {  
  2.     title: 'TreeGrid(多列樹示例)',  
  3.     renderTo: Ext.getBody(),  
  4.     width : 200,  
  5.     height : 120,  
  6.     fields: ['name''description'],  
  7.     columns: [{  
  8.         xtype: 'treecolumn',//樹狀表格列  
  9.         text: '名稱',  
  10.         dataIndex: 'name',  
  11.         width: 100,  
  12.         sortable: true  
  13.     }, {  
  14.         text: '描述',  
  15.         dataIndex: 'description',  
  16.         flex: 1,  
  17.         sortable: true  
  18.     }],  
  19.     root: {  
  20.         name: '樹根',  
  21.         description: '樹根的描述',  
  22.         expanded: true,  
  23.         children: [{  
  24.             name: '節點一',  
  25.             description: '節點一的描述',  
  26.             leaf: true  
  27.         }, {  
  28.             name: '節點二',  
  29.             description: '節點二的描述',  
  30.             leaf: true  
  31.         }]  
  32.     }  
  33. });  


三、樹面板中的複選框示例 
Javascript代碼  收藏代碼
  1. var tree = Ext.create('Ext.tree.Panel', {  
  2.     title: '複選框示例',  
  3.     width : 150,  
  4.     height : 100,  
  5.     renderTo: Ext.getBody(),  
  6.     root: {  
  7.         text: '樹根',//節點名稱  
  8.         expanded: true,//默認展開根節點  
  9.         children: [{  
  10.             text: '節點一',//節點名稱  
  11.             checked : true,//默認選中  
  12.             leaf: true//true說明爲葉子節點  
  13.         }, {  
  14.             text: '節點二',//節點名稱  
  15.             checked : false,//默認不選中  
  16.             leaf: true//true說明爲葉子節點  
  17.         }]  
  18.     }  
  19. });  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章