jQuery MiniUI 开发教程 树形控件 树操作:增加、删除、修改、移动(六)
参考示例:增加、删除、修改节点
增加节点
var tree = mini.get("tree1");
var node = tree.getSelectedNode();
var newNode = {};
tree.addNode(newNode, "before", node);
删除节点
var node = tree.getSelectedNode();
tree.removeNode(node);
编辑节点
var node = tree.getSelectedNode();
tree.beginEdit(node);
移动节点
tree.moveNode(node, targetNode, "before");
posted on 2012-12-04 15:31 nikofan 阅读(433) 评论(1) 编辑 收藏
Feedback
# re: jQuery MiniUI 开发教程 树形控件 树操作:增加、删除、修改、移动(六)[未登录] 2012-12-05 13:56 1
Ext.onReady(function() {
Ext.Direct.addProvider(Ext.app.REMOTING_API);
Ext.QuickTips.init();
myTreeLoader = new Ext.tree.TreeLoader( {
applyLoader:false,
paramsAsHash: true,
baseParams : {
id : 'oid',
foo: 'empty'
},
directFn: treeProvider3.getTreeGrid
});
var tree = new Ext.ux.tree.TreeGrid({
title: 'Core Team Projects',
width: 600,
height: 500,
id: 'usedByPartsTreeGridID',
//rootVisible:false, //不显示根节点
renderTo: Ext.getBody(),
//enableDD: true,//是否可以移动
//autoScroll: true,//是否有滚动条
loader: myTreeLoader,
columns:[{
header: 'Task',
dataIndex: 'task',
width: 200
},{
header: 'Duration',
width: 200,
dataIndex: 'duration'
},{
header: 'Assigned To',
width: 200,
dataIndex: 'user'
}]
});
myTreeLoader.on("beforeload", function(treeLoader, node) {
alert(node.attributes.Task);
Ext.getCmp('usedByPartsTreeGridID').getLoader().baseParams.id = node.attributes.Task;//node.attributes.task为节点属性task的值
Ext.getCmp('usedByPartsTreeGridID').getLoader().baseParams.foo = count;
Ext.getCmp('usedByPartsTreeGridID').getRootNode().reload();
}, this)
});
@ExtDirectMethod(value = ExtDirectMethodType.TREE_LOAD, group = "tree")
public List<TreeVO> getTreeGrid(
@RequestParam(value = "id") String id,
@RequestParam(value = "foo", defaultValue = "defaultValue") String foo) {
List<TreeVO> secondresult = new ArrayList<TreeVO>();
List<TreeVO> childresult = new ArrayList<TreeVO>();
List<TreeVO> result = new ArrayList<TreeVO>();
for (int i = 1; i <= 5; ++i) {
TreeVO children = new TreeVO();
children.setTask(i + "second level children");
children.setDuration(i + " level children");
children.setLeaf("true");//是否叶子节点,true为是,如果不是叶子节点,则不能设置值
children.setIconCls("task");
children.setUser(i + "second user");
secondresult.add(children);
}
for (int i = 1; i <= 5; ++i) {
TreeVO children = new TreeVO();
children.setTask(i + "first level children");
children.setDuration(i + " level children");
children.setIconCls("task-folder");
children.setUser(i + "first user");
children.setChildren(secondresult);//secondresult List<TreeVO>类型
childresult.add(children); www.zzzyk.com
}
TreeVO rootNode = new TreeVO();
rootNode.setTask("Project: Shopping");
rootNode.setDuration("Project 0 level children");
rootNode.setExpanded("true");
rootNode.setIconCls("task-folder");
rootNode.setUser("Tommy Maintz");
rootNode.setChildren(childresult);
result.add(rootNode);
return result;
}
补充:web前端 , JavaScript ,