I have a split button in a grid. When I click the split button the context menu shows. When I click on the context menu the OnItemClick fires and I can get the context item selection. But what I can't figure out how to do is get the datakey value for the radgrid row where I click the button. If I select the row first I can get the datakey value via RowSelected or RowSelecting. But niether of those events fire when I click on the split button because its OnClientClicked fires. I'd like to get that value without having to select the row first.
<
telerik:RadContextMenu
ID
=
"radCtxMenuActions"
runat
=
"server"
CausesValidation
=
"true"
OnItemClick
=
"radCtxMenuActions_ItemClick"
>
<
Items
>
<
telerik:RadMenuItem
Text
=
"Option 1"
/>
<
telerik:RadMenuItem
Text
=
"Option 2"
/>
<
telerik:RadMenuItem
Text
=
"Option 3"
/>
</
Items
>
</
telerik:RadContextMenu
>
protected void radCtxMenuActions_ItemClick(object sender, RadMenuEventArgs e)
{
int id = Convert.ToInt32(Request.Form["radGridClickedRowValue"]);
switch (e.Item.Text)
{
case "Option 1":
// do action with id
break;
}
}
if (args.IsSplitButtonClick() || !sender.get_commandName())
{
// get selected row here and save to hidden field so I can use it in RadContextMenu OnItemClick
var id = ?????
document.getElementById("radGridClickedRowValue").value = id;
var currentLocation = $telerik.getLocation(sender.get_element());
var contextMenu = $find("<%=radCtxMenuActions.ClientID%>");
contextMenu.showAt(currentLocation.x, currentLocation.y + 22);
}