Adding a querystring to a menu item's action?

12 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
    2304 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. 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 :\

  4. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2304 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!
  5. Kiran
    Kiran avatar
    21 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});

     

     

     

  6. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2304 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.

     
  7. Kiran
    Kiran avatar
    21 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

  8. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2304 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.

     
  9. Kiran
    Kiran avatar
    21 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

     

  10. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2304 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.

     
  11. GPC
    GPC avatar
    7 posts
    Member since:
    Jul 2018

    Posted 16 Sep 2018 in reply to Dimiter Madjarov Link to this post

    Hi Dimiter,

    My context menu is targeted on a Telerik grid. So when user right clicks on the grid and selects a context menu option, I need to pass in some of the dataItems's of the selected row of the grid as parameter to the Action method of the selected context menu item. How can I achieve this?

    My detailed question is here

  12. Joana
    Admin
    Joana avatar
    205 posts

    Posted 18 Sep 2018 Link to this post

    Hi Wasim,

    I already reply in the original thread regarding the ContextMenu and Grid integration. To facilitate the communication, let's keep the discussion in one thread.

    For your convenience, I am pasting the reply here too:

    In order to pass the selected row's dataItem of the Grid to the controller for the specific ContextMenu item selected, I could think of two approaches:

    1. Perform an ajax request on Context Menu Item selection and pass the required data to the server. I suppose that you are aware of this approach as you have mentioned in a comment that you have already tried it. But if i understand correctly, this approach interfere the export to pdf functionality of your project.

    2. Store the required fields of the dataItem in a HiddenField. This way you will be able to change its value on the client-side on open of the ContextMenu.

    Please, give a try the approach with hidden field and let me know if it fits your scenario.


    Regards,
    Joana
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top