|
Rank: Member Groups: Member
Joined: 9/1/2010 Posts: 20
|
Hi, I tried to rename a node in a tree, using javascript, when a button is clicked:
Code: JavaScript
function Button2_onclick() {
alert("start");
var tree = eo_GetObject("TreeView1");
var node = tree.getSelectedNode();
node.setText("myNewText");
alert("End");
}
The renaming was successful until I selected another node on the tree. The node I just renamed, change back to the original text. Please help. Regards, Alex
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Currently the TreeView does not save any changes made on the client side by JavaScript. This is consistent with any other set function such as setLeftIcon, setValue, etc. TreeView does have the ability to save changes made by the user through in place editing. Currently you can put the node into edit mode by calling the node's beginEdit function but there is no way to do a "silence" editing without user seeing the textbox. We will see if we can add that so that you can call that function instead of setText to rename a node.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 9/1/2010 Posts: 20
|
Hi,
Can you give me the example of script using beginEdit. It's okay if we must use beginEdit and so, as long as user not doing the editting.
Please help.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You can do something like this:
Code: JavaScript
treeNode.setText("myNewText");
treeNode.beginEdit();
The problem is this will put that node into edit mode (thus displaying a textbox on that node). And in order to bring that node out of edit mode, you have to set the treeview's selected node to something else. We should be able to extend beginEdit method for you and provide you a new build in a few days that would allow you to put the node into edit mode, change text and bring the node out of edit mode immediately. So it will be something like this in the new build:
Code: JavaScript
treeNode.beginEdit("myNewText", true);
Note the second argument is a new argument that instructs beginEdit to submit the changes right away. Thanks!
|
|
Rank: Member Groups: Member
Joined: 9/1/2010 Posts: 20
|
That would be great, as I need it urgently. Thanks for the effort. Looking forward anxiously for the new build.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
We have posted a new build that should address this issue. Please see your private message for the download location.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 9/1/2010 Posts: 20
|
Hi, I really appreciate your quick response and the new build is generated sooner than I expected. So I have installed the new build and implemented it such this:
Code: JavaScript
function Button1_onclick() {
var tree = eo_GetObject("TreeView1");
var node = tree.getSelectedNode();
node.beginEdit("myNewText007",true);
}
It works. The node was renamed permanently, even after I refreshed the page. But there is still one thing; if I renamed a node, then I refresh the page before I click on another node or anything else, the node I just renamed, back to it's original text. Did I code it wrongly? Pls, help. Regards, Alex
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
That is normal. When you refresh a page you meant to discard everything and start over again. That's how refresh supposes to work.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 9/1/2010 Posts: 20
|
Hi,
But if I rename a node, then click on another node, then refresh. The renamed node would not change back.
Regards.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
It’s the same. Refreshing = Discarding everything and start over. Unless you saved your changes somewhere on your backend before the refresh, all your changes will be discarded. That is how it supposes to work. If you wish to save changes, you can handle the TreeView’s NodeRenamed event.
If you are still confused about this behavior, you may want to ask someone around you to explain to you. We do not know how to explain it better ---- there is really nothing to explain on this. The TreeView is working correctly as it should be.
Thanks
|
|