[code="java"]
//公共变量-----------------------------------------------------------------
var tree;
var panels;
var url;
[/code]
[code="java"]
//建立一棵树---------------------------------------------------------------
function createTree(){
var root = new Ext.tree.AsyncTreeNode({
id:'0',
text:'部门'
});
tree = new Ext.tree.TreePanel({
loader:new Ext.tree.TreeLoader({dataUrl:'/KJ222Demo/department/getTrees'}),
root:root,
autoScroll:true,
border:false,
rootVisible:false
});
tree.on('beforeload',function(node){
tree.loader.dataUrl = '/KJ222Demo/department/getTrees?parentId='+node.id;
});
tree.on('click',function(node){
//alert('点击的这个部门的id是:'+node.id);
//openTab(node.id);
node.expand();
node.select();
});
root.expand();
root.select();
}
[/code]
[code="java"]
//搜索部门---------------------------------------------------------------
function searchTree(){
var name = Ext.getCmp('txt-name').getValue();
Ext.Ajax.request({
url:'/KJ222Demo/department/findNode',
params:{
name:name
},
success:function(response){
var data = Ext.util.JSON.decode(response.responseText);
if (data.success) {
tree.root.reload();
tree.selectPath(data.path,null,function(succ,lastNode){
lastNode.expand();
});
} else {
Ext.Msg.alert('提示','没有相关的部门信息!');
}
}
})
}
[/code]
[code="java"]
//页面加载时执行的操作-------------------------------------------------
Ext.onReady(function(){
createTree();
jindu();
createPanel();
alert(panels)
createLayout();
});
[/code]
[code="java"]
//布局管理--------------------------------------------------------------
function createLayout(){
new Ext.Viewport({
layout:'border',
items:[{
title: '部门管理',
collapsible: true,
region:'west',
width: 100,
items:tree,
tbar:[{
id:'txt-name',
xtype:'textfield'
},{
xtype:'button',
text:'查找',
handler:searchTree
}]
},{
region:'center',
id:'panel',
xtype:'panel',
//activeTab:0,
layout:'fit',
contentEl:'dms-content',
items:panels
}]
})
}
[/code]
[code="java"]
//搭建一个右面的面板,里面包含了一个grid-------------------------------------
function createPanel(){
grid = new Ext.grid.GridPanel({
height:400,
store:ds,
columns:[
{header:'行号',renderer:function(value, cellmeta, record, rowIndex){return rowIndex + 1;}},
{header:'编号',dataIndex:'code',width:100},
{header:'名称',dataIndex:'name',width:100},
{header:'其它',dataIndex:'other',width:100}
],
tbar:[{
text:'增加'
//iconCls:'tool-add'
},'-',{
text:'修改',
iconCls:'tool-edit',
// iconCls:'tool-edit',
handler:function(){
edit(grid);
}
},'-',{
text:'删除'
//iconCls:'tool-cut'
// iconCls:'tool-cut',
// handler:this.destroyItem.createDelegate(this)
},'-',{
text:'查询'
//iconCls:'tool-find',
//handler:this.showQueryWindow.createDelegate(this)
},'-',{
text:'导出到excel'
//iconCls:'tool-find',
//handler:this.onPrint.createDelegate(this)
}],
bbar:new Ext.PagingToolbar({
store:ds,
pageSize:20
}),
border:false
});
panels = new Ext.Panel({
border: false,
layout:'fit',
items: grid
});
}
[/code]
[code="java"]
//定义的数据源--------------------------------------------------------------------------
var ds = new Ext.data.JsonStore({
url:'/KJ222Demo/Demo/getAll', //由etmvc映射到DeviceController类中的getDevices方法
fields:[
'id','code','name','other'
],
baseParams:{
limit:20
},
totalProperty:'total',
root:'demo'
});
ds.load({
params:{start:0}
});
[/code]
---------------------------------------------问题---------------------------------------------------
初始化时会显示一个列表
当我点击一个树的节点的时候,panel里的grid内容跟着变(根据这个节点查询出来的)
请问谁知道怎么做?
[b]问题补充:[/b]
希望能针对上面的代码给个具体的解决方案