Adding server side event breaks client side change tracking

2 posts, 0 answers
  1. Tom Parks
    Tom Parks avatar
    5 posts
    Member since:
    May 2008

    Posted 10 Sep 2009 Link to this post

    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) 

    1 <telerik:RadTreeView ID="tvwCategory" runat="server" EnableDragAndDrop="true" EnableDragAndDropBetweenNodes="true" AllowNodeEditing="true" OnClientNodeDropping="onNodeDropping"  OnClientContextMenuItemClicked="onClientContextMenuItemClicked" 
    2   OnClientNodeEdited="onClientNodeEdited"  onprerender="tvwCategory_PreRender"   
    3   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
  2. Yana
    Admin
    Yana avatar
    4982 posts

    Posted 15 Sep 2009 Link to this post

    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.
Back to Top