Hello,
I have a RadContextMenu attached to a RadGrid like shown in this demo: http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandmenu/defaultcs.aspx?product=grid.
I would like to be able to conditionally disable/enable items in the ContextMenu based on a data element in the Grid. How can I do this? For example, if a field is "true", I would like to have a specific Context Menu Item enabled - otherwise it will be disabled.
Thanks!!
I have a RadContextMenu attached to a RadGrid like shown in this demo: http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandmenu/defaultcs.aspx?product=grid.
I would like to be able to conditionally disable/enable items in the ContextMenu based on a data element in the Grid. How can I do this? For example, if a field is "true", I would like to have a specific Context Menu Item enabled - otherwise it will be disabled.
Thanks!!
4 Answers, 1 is accepted
0
0
John
Top achievements
Rank 1
answered on 01 Oct 2009, 01:54 PM
Interesting. It seems the condition for that is the index of the row. I'm looking to base the condition on a data element. Any advice for that? I'll hack away at the provided solution to see if I can figure it out, but if you have any guidance I would appreciate it.
0
Schlurk
Top achievements
Rank 2
answered on 01 Oct 2009, 04:07 PM
I believe the function you should take a look at would be get_element():
This should be able to allow you to play around with the particular grid element that was clicked. For more info on the client-side events/functions/properties of the RadGrid check out the documentation.
| function getGridDivElement() |
| { |
| var grid= $find("<%= RadGrid1.ClientID %>") |
| var gridDiv = grid.get_element(); |
| } |
This should be able to allow you to play around with the particular grid element that was clicked. For more info on the client-side events/functions/properties of the RadGrid check out the documentation.
0
John
Top achievements
Rank 1
answered on 01 Oct 2009, 05:59 PM
Thanks for your help. Here is how I got it working:
I called this before the menu.show method so I didn't get the blinking with items appearing or disappearing after the menu was shown. This requires the developer to declare the fields in as ClientDataKeyNames.
| //This function handles dynamically enable/disabling and hiding/showing items in grid context menu... |
| function SetDynamicItems(menu, dataItem) { |
| //Set "Undecline Dealer" item... |
| var menuItem = menu.findItemByText("Undecline Dealer"); |
| if (dataItem.getDataKeyValue("IsDeclined") == 'False') { |
| menuItem.hide(); |
| } |
| else { |
| menuItem.show(); |
| } |
| } |
I called this before the menu.show method so I didn't get the blinking with items appearing or disappearing after the menu was shown. This requires the developer to declare the fields in as ClientDataKeyNames.