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

Adding server side event breaks client side change tracking

1 Answer 64 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tom Parks
Top achievements
Rank 1
Tom Parks asked on 10 Sep 2009, 05:27 PM

I have some code that has been working for a while, where I do stuff mostly on the client side (drag drop/delete/edit).  I process the client transactions saved in the ClientChanges collection on the server when a Save button is clicked   I had a need to add code to a context menu to allow adding a child to a selected node.  I specifically needed to have the node show up in edit mode right away for the user to add the node text.  I couldn't get this to work on the client side, so I saw a server side sample on your website that does exactly what I needed  (right click on node and select 'new folder' in context menu  http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/contextmenu/defaultcs.aspx). 

So I added the onContextMenuItemClick server event to the .aspx  (line 3 below) 

<telerik:RadTreeView ID="tvwCategory" runat="server" EnableDragAndDrop="true" EnableDragAndDropBetweenNodes="true" AllowNodeEditing="true" OnClientNodeDropping="onNodeDropping"  OnClientContextMenuItemClicked="onClientContextMenuItemClicked" 
  OnClientNodeEdited="onClientNodeEdited"  onprerender="tvwCategory_PreRender"   
  oncontextmenuitemclick="tvwCategory_ContextMenuItemClick"

And I of course add the corresponding code to the .aspx.cs for this method just as in the example.  This works great.  But now my code that processes client side changes for Drag and Drop is not working any more.  The client side delete and edit transactions still appear correctly in the ClientChanges collection, but transactions related to Drag and Drop are not there anymore.  If I remove the server side onContextMenuItemClick event code from the .aspx and .aspx.cs, then the Drag and Drop code works again!

What is happening here?  How to fix/ work around it?  I am using version 2008.3.1125.20

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 15 Sep 2009, 01:40 PM
Hello Tom,

ClientChanges collection is preserved only the first time the page postbacks, so if you make some drag and drop transactions, then open the context menu and click an item, the page postbacks and you can see in ContextMenuItemClick event handler the client changes, but if you after that click "Save" button, the ClientChanges collection will be already empty.

Best regards,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TreeView
Asked by
Tom Parks
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or