[code="java"]Ext.onReady(function(){
treePanel = new Ext.tree.TreePanel({
id:'tree-mianban',
el:'treeDiv',
border:true,
autoScroll:true,
animate:true,
width:180,
height:448,
enableDD:true,
containerScroll: true,
rootVisible:false,
layout:'accordion',
title:'主管部门',
root:new Ext.tree.AsyncTreeNode({
text: '部门',
draggable:false,
id:'0'}),
loader:new Ext.tree.DWRTreeLoader({
dataUrl:baseAjax.loadTopOrgByTypeId
})
});
treePanel.render();
treePanel.getRootNode().expand();
treePanel.on('click',treeClick);
});
[/code]
现在的问题是 后台baseAjax类的方法loadTopOrgByTypeId要接受两个参数,id:'0'是传递了一个参数id,
问题就是 怎么把两个参数传递过去?
[b]问题补充:[/b]
1楼的提供的网址
我试过了
实现不了.....
[b]问题补充:[/b]
2楼能细说一下 baseParams 的用法吗?
[b]问题补充:[/b]
3楼正解.....
按照他的方法可以实现传递参数。
但是又出现一个问题
如6楼所述....
在展开节点的时候 展不开.... 是后台返回数据的问题嘛?望6楼详解。
[b]问题补充:[/b]
问题解决。。。
按照3楼的说法 来传递参数正确。
按照6楼的说法 可以实现最终效果。。
不过6楼的传参 貌似有点小问题。。可能是我测试的时候有问题吧。
总之 谢谢各位。
这分也不多。。给3楼啦。
看下你用的Ext.tree.DWRTreeLoader的源码,和给出的url里面的源码是否一致.
也就70行代码而已.很容易看懂的
[code="java"]callParams.push(node.id);
if(node.attributes.queryParam != null)this.queryParam = node.attributes.queryParam;
callParams.push(this.queryParam);
callParams.push({callback:success, errorHandler:error});
this.transId=true;
this.dwrMethod.apply(this, callParams);[/code]
看:[url]http://www.iteye.com/topic/212587[/url]
节选:
[quote]如果需要向后台传递多个参数,为root.attributes.queryParam赋予一个Map对象既可,如
root.attributes.queryParam = {searchName:'xxxx',searchType:'yyyy'}; [/quote]
另外,TreeLoader还有个属性
baseParams : Object
An object containing properties which specify HTTP parameters to be passed to each request for child nodes.
TreeLoader
baseParams行不通,看了源码,如3楼那样.
必须用queryParam.
给个思路吧,加个事件:
tree.loader.on('beforeload',function(treeLoader,node){
this.baseParams.id = node.attributes[id];
});
试着:
[code="java"]
root:new Ext.tree.AsyncTreeNode({
text: '部门',
draggable:false,
id:'0',
//这时候你的dwr会接受3个参数,分别是 '0','参数2','参数3'
queryParam:['参数2','参数3']
})
[/code]
如果你的子节点也要这样,那你的json返回里面必须包括queryParam这个属性
返回的json是
{
id:3,
text:'子节点3',
queryParam:['参数2','参数3']
}