---
title: "Ext6 treePanel默认加载两级或多级本地树信息其他加载远程数据"
author: "yrandy"
date: "2018-03-21T16:54:17Z"
tags: []
categories: ["Web前端"]
slug: "ext6-treepanel"
draft: false
lastmod: "2018-03-21T16:54:17Z"
id: 2414148
url: "https://yrandy.iteye.com/blog/2414148"
---

代码使用如下：

 

Ext.define('user.view.AreaTree', {

extend : 'Ext.tree.Panel',

title : '树目录',

width : 200,

height : 200,

region : 'west',

**store : new Ext.data.TreeStore({**  //这里不能指定root,否则默认不会加载，会直接走proxy远程

**proxy : {**

**type : 'ajax',**

**url : 'http://xxx:80/remote.jsp'**

**}**

**}),**

root : {  //在treePanel上指定root，先加载treePanel上的root数据，其次展开再通过store进行proxy加载

id : '0',

expanded : true,

children : [{

id : '1',

text : '一级分类1'

}, {

id : '2',

text : '一级分类2'

}]

},

rootVisible : false,

border : false,

autoScroll : true,

listeners : {

itemcontextmenu : function(th, record, item, index, event, eOpts) {

event.preventDefault();

Ext.create('Ext.menu.Menu', {

width : 100,

height : 100,

floating : true, // usually you want this set

items : [{

text : '新建',

iconCls : 'add16',

handler : function() {

alert('xxxx');

}

}, {

text : '修改'

}, {

text : '删除'

}]

}).showAt(event.getXY());

}

                })

 

 Ext6,treePane和treeStore关于层级加载顺序，还有待学习，这里先做笔记