tree是个权限导航树 能进行修改什么的 有的发邮件290806418@qq.com 急啊 ~~~~~~~~~~~~~~~~~~~
[code="java"]
Ext.onReady(function() {
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'check-nodes.json'
},
sorters: [{
property: 'leaf',
direction: 'ASC'
}, {
property: 'text',
direction: 'ASC'
}]
});
var tree = Ext.create('Ext.tree.Panel', {
store: store,
rootVisible: false,
useArrows: true,
frame: true,
title: 'Check Tree',
renderTo: 'tree-div',
width: 200,
height: 250,
dockedItems: [{
xtype: 'toolbar',
items: {
text: 'Get checked nodes',
handler: function(){
var records = tree.getView().getChecked(),
names = [];
Ext.Array.each(records, function(rec){
names.push(rec.get('text'));
});
Ext.MessageBox.show({
title: 'Selected Nodes',
msg: names.join('<br />'),
icon: Ext.MessageBox.INFO
});
}
}
}]
});
});
[/code]
这个是extjs里面提供的例子,上面的“check-nodes.json”就是tree需要的数据格式:
[code="java"]
[{
"text": "To Do",
"cls": "folder",
"expanded": true,
"children": [{
"text": "Go jogging",
"leaf": true,
"checked": true
},{
"text": "Take a nap",
"leaf": true,
"checked": false
},{
"text": "Climb Everest",
"leaf": true,
"checked": false
}]
},{
"text": "Grocery List",
"cls": "folder",
"children": [{
"text": "Bananas",
"leaf": true,
"checked": false
},{
"text": "Milk",
"leaf": true,
"checked": false
},{
"text": "Cereal",
"leaf": true,
"checked": false
},{
"text": "Energy foods",
"cls": "folder",
"children": [{
"text": "Coffee",
"leaf": true,
"checked": false
},{
"text": "Red Bull",
"leaf": true,
"checked": false
}]
}]
},{
"text": "Remodel Project",
"cls": "folder",
"children": [{
"text": "Finish the budget",
"leaf": true,
"checked": false
},{
"text": "Call contractors",
"leaf": true,
"checked": false
},{
"text": "Choose design",
"leaf": true,
"checked": false
}]
}]
[/code]
你只需要使用struts2产生这样的json数据就可以了。产生json,可以使用struts2-json-plugin.jar这个插件,具体使用你可以参考一下:[url]http://struts.apache.org/2.2.3/docs/json-plugin.html[/url]
你的问题太不具体了,关于tree的用法,你可以先参考一下官方提供的例子,然后自己改动。
把你得问题在往清楚的说一下了啊!你要的是不是tree 节点前面有个选项框,可以选中吗?
tree需要返回什么样的数据,你只需要看看ext里面关于tree的例子就知道了。至于返回json数据,肯定是用一下工具,如果你使用struts2的话,它有json插件,配置了就可以用了。