Current filter:
                                You should refresh the page.
                                0
                                  • Can you please tell me how to make the current menu selection state persist even when other pages are displayed that are not linked from the menu?


                                    My site's navigation only has top-level menu items and I do not want to show any sub-items for the various actions such as Create Claim, Edit Claim etc. I just want any claim-related view to keep the "My Claims" menu item selected. I have previously tried to achieve this with hidden sub-items but it didn't work consistently.


                                    So, in summary if a user requests the URL "/Claims" I want the "My Claims" menu item to be selected. If the user requests "/Claims/Edit/1" I would like "My Claims" to remain selected.


                                    I have the following code in my _layout.cshtml view:


                                    <para>@Html.DevExpress().Menu(

                                    settings =>

                                    {

                                    settings.Name = "siteMenu";

                                    settings.ShowAsToolbar = false;

                                    settings.AllowSelectItem = false;

                                    settings.SelectParentItem = true;

                                    settings.MaximumDisplayLevels = 1;

                                    settings.SyncSelectionMode = SyncSelectionMode.CurrentPath;


                                    settings.Items.Add(item => {

                                    item.Text = "My Claims";

                                    item.NavigateUrl = "~/Claims";

                                    });

                                    settings.Items.Add(item => {

                                    item.Text = "Help";</para> item.NavigateUrl = "~/Home/Help";

                                    });

                                    }).GetHtml()


                                    Thanks.

                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                A solution for this task requires additional coding.

                                Disable the SyncSelectionMode setting, it is useless in this scenario.

                                In a controller's constructor, add an indicator to the ViewBag object or to the ViewData collection to indicate which controller's method has been called.

                                In the ' _layout.cshtml ' View use the indicator value to select a corresponding Menu item in code.

                                • 06.26.2012

                                  Thanks Vladimir. I now manually set the items to Selected according as per your suggestion as they are added, i.e.

                                  settings.Items.Add(item => {
                                                                  item.Text = "My Claims";
                                                                  item.NavigateUrl = "~/Claims";
                                                                  if (controller == "Claims")
                                                                  {
                                                                      item.Selected = true;
                                                                  }
                                  }

                                  ... and everything works fine. Many thanks.

                                • You are always welcome!

                                You must  log in  or  register  to leave comments
                                You must  log in  or  register  to leave an answer

                                Is your intention to post an answer to your own question?

                                • If so, then proceed.
                                • If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
                                • If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.