TreeView using webmethod refresh on context menu click

1 Answer 30 Views
TreeView
Van
Top achievements
Rank 1
Iron
Iron
Van asked on 23 Mar 2022, 02:51 PM

We are using the radtreeview with a webmethod to populate nodes with persistloadondemandnodes set to true.   Once the user clicks an item on the tree context menu it calls the codebehind which modifies the data.   At this point we call DataBind on the tree expecting it to call back to the web method to retieve the updated data.  However it never calls back to server's webmethod.  The tree does refresh client side since has been added to the ajax manager - but refresh is just the same data as before context menu click.   

How do we get the treeview to refresh it's data after the server-side context menu handler changes the data in the source ???

1 Answer, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 28 Mar 2022, 12:43 PM

Hi Van,

The TreeView is persisting the loaded nodes through postback. What you say sounds like you are rebinding the TreeView, so you are recreating completely the nodes. 

That means any "cached" items will be lost and you would need to recreate the whole hierarchy with the new nodes. Also, as you are changing the data, there is a chance the previously expanded nodes no longer exist.

With that said, you should expand anew the nodes, if they exist, and they will be persisted until the next rebind. If you need to just refresh the nodes loaded via the web method, you should use a similar technique as explained here:

Regards,
Peter Milchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Van
Top achievements
Rank 1
Iron
Iron
commented on 28 Mar 2022, 01:04 PM

Hi Peter,

Thank you for the info.   After I posted my question  I found the article you referenced, and implemented it.  It does work as described,  however when you have a large number of nodes that are collapsed, cleared and re-expanded the visual result is not good.  Plus having to deal with re-setting the current selection.  Am looking into adding additional javascript to update the tree via another service call behind the scenes.  Feel free to close this thread - your answer is correct.

Tags
TreeView
Asked by
Van
Top achievements
Rank 1
Iron
Iron
Answers by
Peter Milchev
Telerik team
Share this question
or