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

[Solved] Maintain PanelBar state between page refreshes

6 Answers 124 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Adam
Top achievements
Rank 1
Adam asked on 23 Oct 2010, 02:21 AM
Hello
I have a PanelBar in a masterpage (Site.master) and would like to know how to maintain the PanelBar's state between page refreshes.

For example, when the user clicks a link in the panel bar an action is invoked and the appropriate page is displayed, however the PanelBar is re-rendered back to its original state

I would like to know if there is some javascript which could iterate through the panelbar and compare the URL with the navigateurl property and if they match the item is then selected and expanded.  Is this possible and does anyone have an example to share?

Thank you
Adam

Site.master below:
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head runat="server">
    <title>
        <asp:ContentPlaceHolder ID="TitleContent" runat="server" />
    </title>
    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
    <%= Html.Telerik().StyleSheetRegistrar()
        .DefaultGroup(group => group.Add("telerik.common.css")
                                    .Add("telerik.hay.css"))
    %>
</head>
<body>
    <div id="header">
        <div id="title">
            <h1>
                <img alt="" src="../../Content/Img/aussielogo1.png" /></h1>
        </div>
        <div id="logindisplay">
            <% Html.RenderPartial("LogOnUserControl"); %>
        </div>
        <div id="menu">
            <ul>
                <li>
                    <%: Html.ActionLink("Dashboard", "Index", "Home")%></li>
                <li>
                    <%: Html.ActionLink("Account", "Home", "Account")%></li>
                <li>
                    <%: Html.ActionLink("About", "About", "Home")%></li>
            </ul>
        </div>
    </div>
    <div class="page">
        <div id="leftcolumn2">
            <asp:ContentPlaceHolder ID="MainContent" runat="server" />
        </div>
        <div id="rightcolumn2">
            <div id="rightcolumn2-bgtop">
            </div>
            <div id="rightcolumn2-content">
                <% Html.Telerik().PanelBar()
                  .Name("PanelBar")
                  .Items(items =>
                  {
                      items.Add().Text("Create").Expanded(true)
                          .Items(subItems =>
                          {
                              subItems.Add().Text("Job");
                              subItems.Add().Text("Customer");
                              subItems.Add().Text("Estimate");
                              subItems.Add().Text("Invoice");
                              subItems.Add().Text("Work Order");
                              subItems.Add().Text("Purchase Order");
                              subItems.Add().Text("Supplier");
                              subItems.Add().Text("Request for Quote");
                              subItems.Add().Text("Contractor");
                          });
                      items.Add().Text("Account")
                        .Items(subItems =>
                        {
                            subItems.Add().Text("View Account").Action("ViewAccountDetails", "Account", new { userName = HttpContext.Current.User.Identity.Name });
                            subItems.Add().Text("Edit Company Details").Action("EditCompanyDetails", "Account");
                            subItems.Add().Text("Edit Address Details").Action("EditAddressDetails", "Account");
                            subItems.Add().Text("Edit Personal Details").Action("EditPersonalDetails", "Account");
                            subItems.Add().Text("Change Password").Action("ChangePassword", "Account");
                        });
                  })
                  .Render();                                   
                %>
            </div>
            <div id="sidebar-bgbtm">
            </div>
        </div>
        <div class="clear">
        </div>
        <div id="footer">
            <%: Html.ActionLink("Privacy Policy", "ViewPrivacy", "Shared")%>
        </div>
    </div>
    <%= Html.Telerik().ScriptRegistrar() %>
</body>
</html>

6 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 25 Oct 2010, 08:00 AM
Hello Adam,

 This is strange as the panelbar is supposed to maintain its state by detecting the current controller and action. This is demonstrated in our sitemap binding demo. Could you please attach a sample project showing your setup? Thanks!

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Adam
Top achievements
Rank 1
answered on 25 Oct 2010, 12:18 PM
Atanas,

The key difference between "Account Home" and "View Account Details" is as follows:

subItems.Add().Text("Account Home").Action("Home", ,Account");                           
subItems.Add().Text("View Account").Action("ViewAccountDetails", "Account", new { userName = HttpContext.Current.User.Identity.Name });
The "View Account Details" option has a querystring containing the users email address.  This is used to retrieve the account details.  PanelBar items which do not contain querystrings will maintain state.

Regards
Adam
0
Atanas Korchev
Telerik team
answered on 25 Oct 2010, 01:35 PM

Hello Adam,

I have edited your post as it contains user name and passwords. Please do not post such data in the forums.

The panelbar makes the checks based on the controller and action name. Query string arguments should not matter. 

I am sending a sample project which shows how the panelbar maintains its state. Could you please modify that project so it shows your setup?

All the best,

Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Adam
Top achievements
Rank 1
answered on 26 Oct 2010, 11:27 AM
Hi Anatas
Ive attached a modified project for you.  Ive added a new PanelBar iteam called TEST and included a querysting.  I still get the same problem.  When I click Index or Home the panelbar maintains state, but the PanelBar will not maintain state with a querystring.

Regards,
Adam

PS: The project was compiled in VS 2010.


0
Accepted
Atanas Korchev
Telerik team
answered on 26 Oct 2010, 03:59 PM
Hi Adam,

 Thank you for your assistance. I was able to reproduce the problem and I confirm that we didn't support query string parameters. Fortunately I implemented that quickly. Find attached the updated build.

Best wishes,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Daniel
Top achievements
Rank 1
answered on 09 Nov 2010, 03:29 PM
Atanas.

Are include this hotfix in the Q3 beta?

Thanks.
Tags
PanelBar
Asked by
Adam
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Adam
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Share this question
or