Hi there,
I have a two-level hierarchical grid with a mastertable and some detailtables. Each row in the detail tables has a column with an asp:Image that has an onclick event. The event opens a RadMenu as seen in the attached screenshot.
Here is the menu:
Here is the column:
And the javascript:
Now, when the user clicks an item in the pop up menu I need to know the index of the row where the image was clicked and which detailtable it happened in. Anyone got an idea on how I could achieve that?
I've seen the example in http://www.telerik.com/community/code-library/aspnet-ajax/general/radmenu-as-context-menu-in-hierarchical-radgrid.aspx which uses the OnRowContextMenu event to store the needed data in two hidden fields, but that event isn't useful in my scenario. I've tried to use OnRowMouseOver instead, but the user might hover over other rows before clicking the menu so that wasn't very reliable:
I have a two-level hierarchical grid with a mastertable and some detailtables. Each row in the detail tables has a column with an asp:Image that has an onclick event. The event opens a RadMenu as seen in the attached screenshot.
Here is the menu:
<Telerik:RadContextMenu ID="RadContextMenu1" runat="server" OnClientItemClicked="OnMoveGroupClicked" |
EnableRoundedCorners="true" EnableShadows="true" AppendDataBoundItems="true" DataSourceID="MilestoneGroupsDS" DataFieldID="pk_miletonegroup_id" DataTextField="milestonegroup_name"> |
<Items> |
<Telerik:RadMenuItem Text="Move to Group:" Enabled="false" /> |
</Items> |
</Telerik:RadContextMenu> |
Here is the column:
<telerik:GridTemplateColumn UniqueName="move_to_group"> |
<ItemTemplate> |
<asp:Image ID="MoveToGroupImg" runat="server" CssClass="cursor_hand" ToolTip="Click to move to another group" ImageUrl="~/Img/folder_arrow.png" onClick="showMenu(event)" /> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
And the javascript:
function showMenu(e) { |
var contextMenu = $find("<%= RadContextMenu1.ClientID %>"); |
if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) |
{ |
contextMenu.show(e); |
} |
$telerik.cancelRawEvent(e); |
} |
Now, when the user clicks an item in the pop up menu I need to know the index of the row where the image was clicked and which detailtable it happened in. Anyone got an idea on how I could achieve that?
I've seen the example in http://www.telerik.com/community/code-library/aspnet-ajax/general/radmenu-as-context-menu-in-hierarchical-radgrid.aspx which uses the OnRowContextMenu event to store the needed data in two hidden fields, but that event isn't useful in my scenario. I've tried to use OnRowMouseOver instead, but the user might hover over other rows before clicking the menu so that wasn't very reliable:
function OnMoveGroupClicked(sender, args) { |
alert("clicked " + document.getElementById("radGridClickedRowIndex").value + " " + document.getElementById("radGridClickedTableId").value); |
} |
function OnRowMouseOver(sender, eventArgs) { |
document.getElementById("radGridClickedRowIndex").value = eventArgs.get_itemIndexHierarchical(); |
var ownerTable = eventArgs.get_tableView(); |
document.getElementById("radGridClickedTableId").value = ownerTable._data.UniqueID; |
} |
<input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex"> |
<input type="hidden" id="radGridClickedTableId" name="radGridClickedTableId"> |
<input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex"> |
<input type="hidden" id="radGridClickedTableId" name="radGridClickedTableId"> |