Hi everyone,
I am having a problem refreshing a node after saving changes on the server side. A summary:
I have an ASP.NET Ajax RadTreeView within an UpdatePanel. A user selects a node and clicks an Edit button. This opens a jQuery dialog in which node data can be changed, such as the description (not the value!). After clicking the Save button in the dialog, a piece of JavaScript triggers a button, which has been registered for AsyncPostBack. On the server side, the node data is saved, and execution returns to a JavaScript method on the page. I then want to refresh the node that has been edited, in order to display, for instance, the new description for the node. I might be going about this the wrong way, but I thought I would be able to accomplish this by refreshing the node's parent, and then re-selecting the node itself. Everything works, accept re-selecting the node that had been edited.
I write the following code:
var tree = FindTree();
var currentNodeValue = tree.get_selectedNode().get_value();
RefreshParentNode();
var currentNode = tree.findNodeByValue(currentNodeValue);
// TODO: why is this node not found?!?
// For now, after update, the parent is selected because the child node is not found, even though it is there...
if (currentNode) {
currentNode.select();
}
The RefreshParentNode function simply finds the parent node of the selected node, and then refreshes it using the following code:
function RefreshNode(node) {
if (node) {
node.collapse();
node.get_treeView().trackChanges();
node.get_nodes().clear();
node.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.WebService);
node.get_treeView().commitChanges();
node.expand();
}
}
All nodes are now displayed correctly, including the updated node with its new description. However, as the comments in the code fragment at the top show, the findNodeByValue function fails to find the node that had been edited, so I can't re-select it.
So, I basically, have two questions:
1) Is there an easier way to get the edited node to display its new description?
2) If not: why is the node not found by findNodeByValue after refreshing the parent, and how can I fix this?
By the way, in case this is not clear from the code fragments above: I am using a LoadOnDemand scenario. Root nodes are loaded immediately, child nodes are loaded using a webservice.
UPDATE: Yes, the FindTree method uses $find and not $get. The tree reference is not the problem...
Regards,
Inge
I am having a problem refreshing a node after saving changes on the server side. A summary:
I have an ASP.NET Ajax RadTreeView within an UpdatePanel. A user selects a node and clicks an Edit button. This opens a jQuery dialog in which node data can be changed, such as the description (not the value!). After clicking the Save button in the dialog, a piece of JavaScript triggers a button, which has been registered for AsyncPostBack. On the server side, the node data is saved, and execution returns to a JavaScript method on the page. I then want to refresh the node that has been edited, in order to display, for instance, the new description for the node. I might be going about this the wrong way, but I thought I would be able to accomplish this by refreshing the node's parent, and then re-selecting the node itself. Everything works, accept re-selecting the node that had been edited.
I write the following code:
var tree = FindTree();
var currentNodeValue = tree.get_selectedNode().get_value();
RefreshParentNode();
var currentNode = tree.findNodeByValue(currentNodeValue);
// TODO: why is this node not found?!?
// For now, after update, the parent is selected because the child node is not found, even though it is there...
if (currentNode) {
currentNode.select();
}
The RefreshParentNode function simply finds the parent node of the selected node, and then refreshes it using the following code:
function RefreshNode(node) {
if (node) {
node.collapse();
node.get_treeView().trackChanges();
node.get_nodes().clear();
node.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.WebService);
node.get_treeView().commitChanges();
node.expand();
}
}
All nodes are now displayed correctly, including the updated node with its new description. However, as the comments in the code fragment at the top show, the findNodeByValue function fails to find the node that had been edited, so I can't re-select it.
So, I basically, have two questions:
1) Is there an easier way to get the edited node to display its new description?
2) If not: why is the node not found by findNodeByValue after refreshing the parent, and how can I fix this?
By the way, in case this is not clear from the code fragments above: I am using a LoadOnDemand scenario. Root nodes are loaded immediately, child nodes are loaded using a webservice.
UPDATE: Yes, the FindTree method uses $find and not $get. The tree reference is not the problem...
Regards,
Inge