This is a migrated thread and some comments may be shown as answers.

SourceDragNode.Value on server is wrong after client-side insert of node

0 Answers 30 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Brent Hetland
Top achievements
Rank 1
Brent Hetland asked on 09 Nov 2012, 07:19 AM
Hi,

I am using version 2011.3.1305.35 of the ASP.NET for AJAX controls.

When I insert a treeview node using client side code, and then drag and drop it, the server side code's SourceDragNode.Value is wrong.  It is the value of the node that is directly ABOVE my inserted node.

I am doing the following:
1)  Using a command on a context menu that uses javascript and an asp ScriptManager and a ServiceReference to insert a node into the treeview.  The javascript that runs in the context menu clicking event is:

selectedFolderParentID = treeNode.get_value();
var UserIDHiddenField = document.getElementById('=UserIDHiddenField.ClientID;');
Portal.UserFavoritesWS.AddFavoriteFolderReturnNode(UserIDHiddenField.value, selectedFolderParentID, folderName, OnFolderInsertCompleted);
eventArgs.set_cancel(true);


2) Then in the callback function (OnFolderInsertCompleted - which is run when the web service returns), I insert the node into the tree at the correct location and put it into edit mode:

function OnFolderInsertCompleted(nodeData) {
var tree = $find("=Me.SavedFavoritesTreeView.ClientID");
var node = new Telerik.Web.UI.RadTreeNode();
tree.trackChanges();
var folderName = nodeData.Text;
var folderID = nodeData.Value;
node.set_text(folderName);
node.set_value(folderID);
node.get_attributes().setAttribute("ObjectTypeID", "80");
node.set_cssClass("savedFolderNode");
var parentNode = tree.findNodeByValue(selectedFolderParentID);
parentNode.get_nodes().add(node);
parentNode.expand();
if (parentNode != tree && !parentNode.get_expanded()) {
    parentNode.set_expanded(true);
}
node.select();
tree.commitChanges();
if (node)
   setTimeout(function () { node.startEdit() }, 20);}


ALL OF THAT WORKS, and I can see that the node's value is indeed the correct ID that was sent back from the node data by the web service.

3) However, if I then immediately Drag and Drop that node (before any other server side page refresh or postback), the server-side SourceDragNode.Value is NOT from the node I've dragged.  It is the value from the node directly ABOVE the node I've dragged.

The result of this, since I have the wrong SourceDragNode.Value, is that the wrong node is being dragged and dropped!

Of course on any full page refresh or postback the SourceDragNode.Value is correct and drag and drop works find because I rebind my treeview on the server, so everything is property sync'ed up at that time...  But it seems like if I do the database insert from the client and also add the node from the client, the server code isn't yet aware of that node (like it is accessing the wrong index item or something).

Any Ideas on what I'm doing wrong or how I can fix this?

Thanks,
Brent

No answers yet. Maybe you can help?

Tags
TreeView
Asked by
Brent Hetland
Top achievements
Rank 1
Share this question
or