How to persist RadPanelBar's state when using Output Caching?
Article Info
Rating: Not rated
|
Article relates to
|
RadPanelBar Classic
RadPanelBar AJAX (Prometheus)
Telerik.Web.UI 2008.1.325
|
|
Created by
|
Nick
|
|
Last modified by
|
Veskoni
|
How to persist RadPanelBar's state when using Output Caching?
Persisting the RadPanelBar's state requires execution of a server-side code. This execution might be prevented by the output caching. To solve the problem you could use the client-side API of the control to find the panel item corresponding to the current URL and expand its parents.
Example
| <script type="text/javascript"> |
| function pageLoad() |
| { |
| var currentUrl = window.location.href.toLowerCase(); |
| var panelbar = $find("<%= RadPanelBar1.ClientID %>"); |
| |
| var currentItem = null; |
| var currentItemTemp = null; |
| for (var i = 0; i < panelbar.get_allItems().length; i++) |
| { |
| if (panelbar.get_allItems()[i].get_linkElement() && |
| currentUrl.indexOf(panelbar.get_allItems()[i].get_linkElement().href.toLowerCase()) > -1) |
| { |
| currentItem = panelbar.get_allItems()[i]; |
| currentItemTemp = currentItem; |
| break; |
| } |
| } |
| |
| while (currentItem && currentItem.get_parent() != panelbar) |
| { |
| currentItem.get_parent().expand(); |
| currentItem = currentItem.get_parent(); |
| } |
| |
| if (currentItemTemp) |
| { |
| currentItemTemp.select(); |
| currentItemTemp.expand(); |
| } |
| } |
| </script> |
Example
| <script type="text/javascript"> |
| var currentUrl = window.location.href.toLowerCase(); |
| var panelbar = <%= RadPanelbar1.ClientID %> |
| var currentItem = null; |
| for (var i = 0; i < panelbar.AllItems.length; i++) |
| { |
| if (panelbar.AllItems[i].LinkElement && |
| currentUrl.indexOf(panelbar.AllItems[i].LinkElement.href.toLowerCase()) > -1) |
| { |
| currentItem = panelbar.AllItems[i]; |
| break; |
| } |
| } |
| |
| if (currentItem) |
| { |
| currentItem.Select(); |
| currentItem.Expand(); |
| } |
| while (currentItem && currentItem.Parent != panelbar) |
| { |
| currentItem.Parent.Expand(); |
| currentItem = currentItem.Parent; |
| } |
| </script> |
| |
Comments
There are no comments yet.
If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!
Please
Sign In
to rate this article.