Ext.define('MyTreeModel', { extend: 'Ext.data.Model', fields: [ 'name','url' ] }); var tree = Ext.create('Ext.tree.Panel',{ width:'200', height:'200', ...
Ext.define('MyTreeModel', { extend: 'Ext.data.Model', fields: [ 'name','url' ] }); var tree = Ext.create('Ext.tree.Panel',{ width:'200', height:'200', // renderTo:'tree_div', displayField:'name', model:'MyTreeModel', root:{ name:'根節點', children:[ {name:'葉子節點1',url:'url1',leaf:true}, {name:'葉子節點2',url:'url2',leaf:true} ] } });
以上是簡單的創建樹的ext框架的方法,數據源是在頁面上寫死的,大家也可以用後臺URL獲取數據源動態的獲取生成一個動態的樹