With the release of the fifth preview version of extjs4, more instances are released. This article introduces the use of extjs4 treepanel. This instance is from the extjs official website. This instance does not limit the drag and drop of Tree nodes. In this example, treestore and ajaxproxy are used.
HTML code:
- <Div id = "tree-Div" style = "width: 250px; Border: 1px solid # c3daf9;"> </div>
JS Code:
- Ext. Require ([
- 'Ext. Tree .*',
- 'Ext. Data .*'
- ]);
- Ext. onready (function (){
- VaR store = new Ext. Data. treestore ({
- Proxy :{
- Type: 'ajax ',
- URL: 'Get-nodes. php'
- },
- Root :{
- Text: 'ext js ',
- ID: 'src ',
- Expanded: True
- },
- Sorters :[{
- Property: 'leaf ',
- Direction: 'asc'
- },{
- Property: 'filename ',
- Direction: 'asc'
- }]
- });
- VaR tree = new Ext. Tree. treepanel ({
- // Autoscroll: True,
- // Enabledd: True,
- // Containerscroll: True,
- Animate: True,
- Border: false,
- Store: store,
- Viewconfig: {plugins: [{ptype: 'treeviewdd'}]},
- Renderto: 'tree-Div ',
- Height: 300
- });
- });
In this example, the returned data is in JSON format and the server must return data similar to the following:
- [{"Text": "layout", "ID": "src \/layout", "CLS": "folder" },{ "text": "componentquery. JS "," ID ":" src \/componentquery. JS "," leaf ": True," CLS ":" file "},{" text ":" Draw "," ID ":" src \/draw ", "CLS": "folder"}]