Adding a querystring to a menu item's action?

10 posts, 1 answers
  1. Nick
    Nick avatar
    86 posts
    Member since:
    Mar 2008

    Posted 21 Feb 2013 Link to this post

    I have a simple menu, but I need to add a querystring to one of the menu items.

    What is the simplest way of doing this?

    @(Html.Kendo().Menu()
          .Name("mainMenu")
          .Items(items => {
            items.Add().Text("Monitors").Action("Index", "Home").Items(subItems => {
              subItems.Add().Text("Monitors Requiring Admin").Action("Index", "Home");
            });
            items.Add().Text("Aliases").Action("Index", "Aliases");
          })
     )
    The url for the sub item needs to have the querystring "?MonitorGrid-filter=HasBeenAdministered~eq~false" added to it as I want a pre-filtered view of the grid when the page loads.

    Cheers,
    Nick
  2. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 21 Feb 2013 Link to this post

    Hi Nick,

    You could add the query string parameters as a RouteValueDictionary to your Action method.

    E.g.

    @{
        RouteValueDictionary routeValues = new RouteValueDictionary();
        routeValues["MonitorGrid-filter"] = "HasBeenAdministered~eq~false";
    }

    subItems.Add().Text("Monitors Requiring Admin").Action("Index", "Home", routeValues);

      Kind regards,
    Dimiter Madjarov
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Nick
    Nick avatar
    86 posts
    Member since:
    Mar 2008

    Posted 21 Feb 2013 Link to this post

    Thanks for the swift reply.  That works great.

    Seems odd there isn't just a .QueryString method or something though :\

  5. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 25 Feb 2013 Link to this post

    Hi Nick,

    I am glad that this approach worked for you. If you think that adding a .QueryString method would be a useful feature, you may consider posting it in our User Voice Portal. If it gathers enough interest from the community, we will consider it for one of our future releases.
     

    Greetings,
    Dimiter Madjarov
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Kiran
    Kiran avatar
    13 posts
    Member since:
    Jul 2014

    Posted 04 May 2015 in reply to Dimiter Madjarov Link to this post

    Hi Nick,

     

    from the above example if I mention the are its not working. can you help the syntax how to use with Area information.

    eg: 

    @{    RouteValueDictionary routeValues = new RouteValueDictionary();    routeValues["MonitorGrid-filter"] = "HasBeenAdministered~eq~false";}
    subItems.Add().Text("Monitors Requiring Admin").Action("Index", "Home", new {area ="Test", routeValues});

     

     

     

  7. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 06 May 2015 Link to this post

    Hello Kiran,


    Could you elaborate what is the exact issue that you are experiencing? If possible please provide an isolated runnable example that demonstrates the problem so we could inspect it locally and provide further assistance.


    Regards,

    Dimiter Madjarov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  8. Kiran
    Kiran avatar
    13 posts
    Member since:
    Jul 2014

    Posted 06 May 2015 in reply to Dimiter Madjarov Link to this post

    I am facing two challenges.

    1. Passing the Encryption Route Dictionary and use then as parameters in ActionResult. (due to security)

    if there any sample on it or example on it.

    2. Passing multiple Route Dictionary values to menu action().

    Thanks,

    Kiran

  9. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 07 May 2015 Link to this post

    Hello Kiran,

    I tried the approach from the previous post in order to add multiple values to the Route Dictionary and it works as expected. Could you test it on your end?

    Regarding the "Encryption Rout Dictionary" I am not exactly sure what are you referring to. Please send a sample code that demonstrates the case.

    Regards,
    Dimiter Madjarov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  10. Kiran
    Kiran avatar
    13 posts
    Member since:
    Jul 2014

    Posted 07 May 2015 in reply to Dimiter Madjarov Link to this post

    Hi Dimiter,

     

    The multiple values to the Route Dictionary is working. 

     But, I am looking to work with encryption values, 

    Ex: http://localhost:1234/Test_&*sdfdsfsdfdsfsdfsdfsdsdfsdfdssd 

    like this. when I click on this kind of line how I can redirect to my route page.? 

    any example on encrypted route value parameters.

     

    Thanks,

    Kiran

     

  11. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 08 May 2015 Link to this post

    Hello Kiran,

    There is no such example at the moment, as the Menu does not have built in functionality for encrypting values. You could check the following page that demonstrates a sample approach on how to achieve this.

    Regards,
    Dimiter Madjarov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready