Context Menu on RadGrid Button

4 posts, 1 answers
  1. Adrian Eng Ying Ming
    Adrian Eng Ying Ming avatar
    16 posts
    Member since:
    Mar 2010

    Posted 15 Jul 2010 Link to this post

    Hi,
        i have a scenario where i am require to invoke the context menu by a button within a radgrid. i have seen there are countless examples of achieving this using onRowContextMenu which is invoked by right clicking on the grid instead. Is there a way to wire up one of the GirdButtonColumn to display the context menu? and still able to know which tableView, and rowIndex trigger the selected Menu?


    thanks,
    Adrian.
  2. Adrian Eng Ying Ming
    Adrian Eng Ying Ming avatar
    16 posts
    Member since:
    Mar 2010

    Posted 15 Jul 2010 Link to this post

    After playing with a few other samples, ive got the context menu to display on a mouse event which is register through ItemDataBound Event as such:

    if (e.Item is GridDataItem)
    {
        GridDataItem dataItem = e.Item as GridDataItem;
        if (dataItem.OwnerTableView.Columns.FindByUniqueNameSafe("EditCommandColumn") != null)
        {
            ImageButton editButton = dataItem["EditCommandColumn"].Controls[0] as  
                                              ImageButton;                   
            editButton.Attributes.Add("onClick", "return ShowMenu(event);");
        }
    }

    function ShowMenu(e , sender){
        var contextMenu = $find("<%= RadContextMenu1.ClientID %>");
        contextMenu.show(e);
        $telerik.cancelRawEvent(e);
        return false;
    }


    the problem arise is, how do i know which row, and which table view that this button who will invoke the ContextMenu reside? How do i implement the concept of onRowContextMenu to this, or is there a better/Alternative way of achieving this (but still retaining button invoking context menu)?

    regards,
    Adrian



  3. Answer
    Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 22 Jul 2010 Link to this post

    Hello Adrian,

    For your convenience I've prepared sample page demonstrating how you can pass current GridTableView and GridDataItem on client event handler. Please find the attachment.

    Regards,
    Nikolay
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. Adrian Eng Ying Ming
    Adrian Eng Ying Ming avatar
    16 posts
    Member since:
    Mar 2010

    Posted 22 Jul 2010 Link to this post

    thanks Nikolay!!! thats just what im looking for :)

    Regards,
    Adrian
Back to Top