Bind context menu to a row of .NET repeater

4 posts, 0 answers
  1. bill
    bill avatar
    5 posts
    Member since:
    Oct 2008

    Posted 19 Feb 2014 Link to this post

    Hi,

    I have a context menu that's inside of a .NET repeater and I'm trying to use the menu's show method when a repeater row is clicked on. The menu shows when a row is clicked but I'm having trouble binding the menu to that particular row - clicking on any row of the repeater causes the menu to be bound to the last row in the repeater. I was wondering if there is a way to do this?

    The code is basically:

    <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="rptSchedules_ItemDataBound">
    <ItemTemplate>
    <tr data='<%# Eval("ddd") %>' runat="server" id="trItemRow" onclick="javascript: showConMenu(this,event); return false;">
    <td>
    <%# GetFormattedDateDisplay(Eval("InTime"))%>
    </td>
    <td>
    <%# GetFormattedDateDisplay(Eval("OutTime"))%>
    </td>
    </tr>
    <telerik:RadContextMenu runat="server" ID="ctxRowMenu" OnItemClick="TelerikMenuItemClick"
    OnClientItemClicked="Client_MenuClicked" OnClientLoad="conMenuLoad">
    <Items>
    <telerik:RadMenuItem Text="Add" runat="server" PostBack="true">
    </Items>
    <Targets>
    <telerik:ContextMenuControlTarget ControlID="trItemRow" />
    </Targets>
    </telerik:RadContextMenu>
    </ItemTemplate>
    </asp:Repeater>

    Thanks,
    Bill
  2. bill
    bill avatar
    5 posts
    Member since:
    Oct 2008

    Posted 19 Feb 2014 Link to this post

    Sorry, I didn't include the JS on my original post:

    function showConMenu(sender, args) {
    var menu = contextMenu;
    if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) {
    menu.show(args); 
    $telerik.cancelRawEvent(e);
    }
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Plamen
    Admin
    Plamen avatar
    2733 posts

    Posted 24 Feb 2014 Link to this post

    Hello Bill,

    As far as I could understand you are trying to add a RadContextMenu on click of an item of the Repeater. I am attaching my sample web page where similar behavior is implemented.

    Hope this will be helpful.

    Regards,
    Plamen
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  5. bill
    bill avatar
    5 posts
    Member since:
    Oct 2008

    Posted 03 Mar 2014 in reply to Plamen Link to this post

    Thank-you Plamen and I'm sorry I did not reply earlier. This is similar to the solution that we did use.

    Thanks,
    Bill
Back to Top