JQueryMiniUI development tutorial tree control Tree operations: add, delete, modify, and move (6)

Source: Internet
Author: User
Reference example: add, delete, and modify a node to add a node vartreemini. get (& quot; tree1 & quot;); varnodetree. getSelectedNode (); varnewNode {}; tree. addNode (newNode, & quot; before & quot;, node); Delete the node varnodetree. g

Example: add, delete, and modify nodes



Add Node

Var tree = mini. get ("tree1 ");
Var node = tree. getSelectedNode ();
Var newNode = {};
Tree. addNode (newNode, "before", node );

Delete a node

Var node = tree. getSelectedNode ();
Tree. removeNode (node );

Edit a node

Var node = tree. getSelectedNode ();
Tree. beginEdit (node );

Mobile Node

Tree. moveNode (node, targetNode, "before ");
Posted on nikofan reading (433) Comments (1) EDIT favorites

Feedback

# Re: jQuery MiniUI development tutorial tree control tree operation: add, delete, modify, move (6) [not logged on] 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: 'id ',
Foo: 'empty'
},
DirectFn: treeProvider3.getTreeGrid

});

Var tree = new Ext. ux. tree. TreeGrid ({
Title: 'core Team Project ',
Width: 600,
Height: 500,
Id: 'usedbypartstreegridid ',
// RootVisible: false, // The root node is not displayed.
RenderTo: Ext. getBody (),
// EnableDD: true, // whether it can be moved
// AutoScroll: true, // whether a scroll bar exists
Loader: myTreeLoader,
Columns :[{
Header: 'task ',
DataIndex: 'task ',
Width: 200
},{
Header: 'duration ',
Width: 200,
DataIndex: 'duration'
},{
Header: 'assigned ',
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 is the value of the node attribute task.
Ext. getCmp ('usedbypartstreegridid'). getLoader (). baseParams. foo = count;
Ext. getCmp ('usedbypartstreegridid'). getRootNode (). reload ();
}, This)

});

@ ExtDirectMethod (value = ExtDirectMethodType. TREE_LOAD, group = "tree ")
Public List GetTreeGrid (
@ RequestParam (value = "id") String id,
@ RequestParam (value = "foo", defaultValue = "defaultValue") String foo ){

List Secondresult = new ArrayList ();
List Childresult = new ArrayList ();
List Result = new ArrayList ();
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"); // whether it is a leaf node. true indicates yes. If it is not a leaf node, the value cannot be set.
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 Type
Childresult. add (children); www.2cto.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;
}
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.