Ext.onReady(function() {
var loader = new Ext.tree.TreeLoader({
url : "service.jsp",
baseParams : {},
listeners : {
"beforeload" : function(loader, node) {
loader.baseParams.method = 'explanTree';
loader.baseParams.id = node.id;
}
}
});
// 异步树节点
var vroot = new Ext.tree.AsyncTreeNode({
text : "问题类型",
id : "root"
});
var button1 = new Ext.Button({
text : "delete",
listeners : {
click : function() {
var root = treePanel.getRootNode();
root.removeAll();
}
}
});
var button2 = new Ext.Button({
text : "refresh",
listeners : {
click : function() {
var root = treePanel.getRootNode();
var n1 = treePanel.getNodeById('n1');
// alert(n1.getPath() );
// panel.expandPath('/source/n1');
root.removeAll();
loader.load(root);
treePanel.expandPath('/root');
}
}
});
// 树panel
var treePanel = new Ext.tree.TreePanel({
width : 200,
useArrows : true,
autoScroll : true,
animate : true,
enableDD : true,
containerScroll : true,
border : false,
loader : loader,
root : vroot,
tbar : [ button1, button2 ],
region : 'west',
collapsed : false,
collapsible : true,
rootVisible : false,
listeners : {
click : function(node) {
store3.baseParams.method = 'dataGrad';
store3.load();
}
}
});
var data1 = [ [ "1", 'Fred Flintstone', 'Fred' ],
[ "2", 'Barney Rubble', 'Barney' ],
[ "3", 'Barney Rubble', 'Barney' ] ];
var store3 = new Ext.data.ArrayStore({
data : data1,
autoDestroy : true,
storeId : 'myStore',
idIndex : 0,
fields : [ 'id', "xx", "vv" ],
baseParams : {},
url : "service.jsp"
});
var grade = new Ext.grid.GridPanel({
title : "数据列表",
store : store3,
height : 300,
columns : [ {
header : "id",
dataIndex : "id"
}, {
header : "name",
dataIndex : "xx"
}, {
header : "pw",
dataIndex : "vv"
} ],
region : 'center'
});
var panel = new Ext.Viewport({
layout : 'border',
items : [ treePanel, grade ]
});
});