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

Expand nodes after PostBack

8 Answers 150 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
EET Group
Top achievements
Rank 2
EET Group asked on 19 Sep 2008, 12:07 PM
I'm using ServerSideCallBack to load my huge product category tree, but after a PostBack (when a user clicks a category to see), the entire tree is reset.

Is there any way that I can expand/recall those nodes which the user loaded/clicked before he made the PostBack? They of course think it's annoying that the tree doesn't "remember" which sub-category they are in.

As I said it's a huge tree, so I don't see any other way than the Load-On-Demand method.

8 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 19 Sep 2008, 12:46 PM
Hello Buffer,

Our online example behaves correctly after postback. What could be different in your case?

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
EET Group
Top achievements
Rank 2
answered on 19 Sep 2008, 01:41 PM
Hi Albert,

Basically I have built my implementation exactly as your example. Only thing is, that to be able to actually use the tree, I make an url redirect on the end-nodes (non-expandable).

I have made this using: radNode.NavigateUrl

Just to cover every option, I have also tried using OnNodeClick, and do a redirect from the NodeEventArgs, but this yields the same result. The tree is reset on the "new" page.

Is it possible to save the tree state across pages, i.e. in a Session object, and restore it from where you "left off"?
0
Accepted
Atanas Korchev
Telerik team
answered on 19 Sep 2008, 02:09 PM
Hello Buffer,

Yes, it is possible. You can use the GetXml method to retrieve the treeview state in xml format and store it in session. Then you can use the LoadXml to retrieve the state of the treeview back from the session and populate it. You can store the xml during NodeClick and load it back in Page_Load.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
EET Group
Top achievements
Rank 2
answered on 23 Sep 2008, 09:49 AM
Thank you, this solved my problem.

I had to make use of the following fix/hack though: http://www.telerik.com/help/aspnet-ajax/troubleshooting-load-on-demand-expand-on-server-side-node-click.html

PS. Now I'm saving a huge XML-tree to the SessionState - do you have any advice for perhaps removing cached sub-trees that are not expanded? (are using single-expansion path.
0
Atanas Korchev
Telerik team
answered on 23 Sep 2008, 10:22 AM
Hi Buffer,

The GetXml method returns the whole treeview state - all nodes and their properties are included. You cannot serialize only the expanded nodes by using GetXml.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
EET Group
Top achievements
Rank 2
answered on 23 Sep 2008, 01:05 PM
Thanks for your answers. I have just one final question.

My top-nodes that have children all use ServerSideCallBack to fetch the children. This works great. Then I use OnNodeClick to handle the server-side GetXml to Session when I click the children (bottom of the tree). This triggers a PostBack.

My problem is now, that once the parents have fetched the children using ServerSideCallBack, they also responds to the OnNodeClick postback. This gives me ugly "do nothing" postbacks if I click a parent node twice.

Is there any way to cancel the postback of parent nodes so only the children generates a NodeClick server side?

Thanks in advance.
0
Accepted
Atanas Korchev
Telerik team
answered on 23 Sep 2008, 01:06 PM
Hello Buffer,

You can set the PostBack property of a RadTreeNode object to false to prevent it from posting back.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
EET Group
Top achievements
Rank 2
answered on 23 Sep 2008, 01:14 PM
Wow, that was easy! I thought it would have cancelled the ServerSideCallBack, but it works like a charm!!

Thank you for excellent service - the tree now does everything I want :)
Tags
TreeView
Asked by
EET Group
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
EET Group
Top achievements
Rank 2
Share this question
or