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

Adding a querystring to a menu item's action?

11 Answers 292 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 21 Feb 2013, 11:21 AM
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

11 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 21 Feb 2013, 04:02 PM
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!
0
Nick
Top achievements
Rank 1
answered on 21 Feb 2013, 04:43 PM
Thanks for the swift reply.  That works great.

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

0
Dimiter Madjarov
Telerik team
answered on 25 Feb 2013, 07:32 AM
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!
0
Kiran
Top achievements
Rank 1
Veteran
Iron
answered on 04 May 2015, 05:59 PM

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});

 

 

 

0
Dimiter Madjarov
Telerik team
answered on 06 May 2015, 07:39 AM

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.

 
0
Kiran
Top achievements
Rank 1
Veteran
Iron
answered on 06 May 2015, 02:31 PM

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

0
Dimiter Madjarov
Telerik team
answered on 07 May 2015, 04:12 PM

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.

 
0
Kiran
Top achievements
Rank 1
Veteran
Iron
answered on 07 May 2015, 08:35 PM

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

 

0
Dimiter Madjarov
Telerik team
answered on 08 May 2015, 10:54 AM

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.

 
0
GPC
Top achievements
Rank 1
answered on 17 Sep 2018, 04:06 AM

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

0
Joana
Telerik team
answered on 18 Sep 2018, 03:28 PM
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.
Tags
Menu
Asked by
Nick
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Nick
Top achievements
Rank 1
Kiran
Top achievements
Rank 1
Veteran
Iron
GPC
Top achievements
Rank 1
Joana
Telerik team
Share this question
or