-
21 Mar 2007 12:34 PM #1
add/delete/rename tree nodes?
add/delete/rename tree nodes?
how can i implement a button that will delete a selected node, add a node to the tree, or do an inline rename of a node?
also how could i access the changed datamodel so i can send back to server as xml or json or whatever?
-
15 Apr 2007 5:21 AM #2
-
15 Apr 2007 6:24 AM #3
hey guys,
to access the selected node of a tree:
adding a new node to the same directory as the selectedNode:Code:var selectedNode = myTree.selModel.selNode;
removing the selectedNode:Code:var newNode = new Ext.tree.TreeNode({id: "foo", text: "foo", leaf: true}); myTree.selModel.selNode.parentNode.appendChild(newNode);
to implement a button doing these operations, you just need to attach a handler to the onClick event of the button doing what I just wrote. Don't forget to watch for the selectedNode being null or not as a user might click on the button without selecting a node.Code:var delNode = myTree.selModel.selNode; myTree.selModel.selNode.parentNode.removeChild(delNode);
-
15 Apr 2007 6:28 AM #4
edit: arrgg I pressed too fast on the edit button and hitted the quote button instead...

As for the renaming of the selectedNode, I'd use an inlineEditor but it will be deprecated soon.
Concerning telling the server side about the changes, I make a XHR call to the server side for each of these operations using the id of the selectedNode and the selected operations. Be sure to have unique IDs if you want to go down that path.
-
9 Jul 2007 1:30 PM #5
how do i get a node / expand a node etc...
how do i get a node / expand a node etc...
I'm defining a function to build a static tree using json.
I need to write a function to get a node by id, appeend, expand collapse and do some similar kind of operations.
How do i do that?
Totally confused with Extjs.. is there any good documentation that gives step up step example?
function doOperation()
{
// How do i get a tree here??
}
-
9 Jul 2007 2:27 PM #6
Read the documentation:
http://extjs.com/deploy/ext/docs/index.html
http://extjs.com/deploy/ext/docs/out...ml#getNodeById
http://extjs.com/deploy/ext/docs/out....html#collapse
http://extjs.com/deploy/ext/docs/out...de.html#expand
http://extjs.com/deploy/ext/docs/out...ml#appendChild
http://extjs.com/deploy/ext/docs/out...e.html#setText
-
1 Apr 2008 1:44 PM #7
Hi,
I've read the documentation, but I can not seem to figure out how from a button to access the tree in order to call getNodeById, collapse, expand, etc.
Nevermind. Sorry to bother. I haven't worked with Javascript in several years and this simple problem just threw me for a loop.
-
24 Apr 2008 1:23 AM #8
When I am trying to delete a node I use this method:
button in the HTML file:Code in the reoder.js file:Code:<button id="button_remove" onClick="Remove_node_and_childs(tree.selModel.selNode)">Remove node and child nodes</button>
unfortunately firebug tell me that tree is not defined, how come?Code:function Remove_node_and_childs(node){ tree.selModel.selNode.parentNode.removeChild(node); }
tree is the name of my tree...
I defined it in thelike that:Code:Ext.onReady(function(){
Thanks for your help.Code:var tree = new Tree.TreePanel({ el:'tree-div', useArrows:true, autoScroll:true, animate:true, enableDD:true, containerScroll: true, loader: new Tree.TreeLoader({ preloadChildren:true, dataUrl:'get-nodes.php' }) });
Ludo
-
14 Mar 2011 3:44 PM #9
Were you able to find out the answer to this problem,I came across similar problem of tree not defined.
-
28 Sep 2011 10:49 PM #10
you have to define var tree = null; outside Ext ready function. As you did, tree variable is only visible within Ext ready scope, so it's not global.
Havent tried, but that's what i see wrong at first sight.Code:<script type="text/javascript"> var tree = null; Ext.onReady(function() { tree = new Tree.TreePanel(.... ... }); </script>
Similar Threads
-
using checkboxes with tree nodes
By eemerge in forum Ext 1.x: Help & DiscussionReplies: 5Last Post: 30 Mar 2007, 6:12 PM -
insert/update/delete - child nodes - dynamically
By saravanan in forum Ext 1.x: Help & DiscussionReplies: 1Last Post: 4 Mar 2007, 2:58 PM -
Copy Tree Nodes Instead of Moving
By FuryVII in forum Ext 1.x: Help & DiscussionReplies: 2Last Post: 28 Feb 2007, 10:13 AM -
swapping two tree nodes
By seldon in forum Ext 1.x: Help & DiscussionReplies: 1Last Post: 15 Feb 2007, 6:38 AM -
Different Style of Nodes in a same Tree ?
By nEEbz in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 14 Dec 2006, 12:11 AM


Reply With Quote