This is a migrated thread and some comments may be shown as answers.

Context Menu on RadGrid Button

3 Answers 80 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Adrian Eng Ying Ming
Top achievements
Rank 1
Adrian Eng Ying Ming asked on 16 Jul 2010, 01:12 AM
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.

3 Answers, 1 is accepted

Sort by
0
Adrian Eng Ying Ming
Top achievements
Rank 1
answered on 16 Jul 2010, 01:35 AM
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



0
Accepted
Nikolay Rusev
Telerik team
answered on 22 Jul 2010, 07:59 AM
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
0
Adrian Eng Ying Ming
Top achievements
Rank 1
answered on 22 Jul 2010, 11:51 AM
thanks Nikolay!!! thats just what im looking for :)

Regards,
Adrian
Tags
Menu
Asked by
Adrian Eng Ying Ming
Top achievements
Rank 1
Answers by
Adrian Eng Ying Ming
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or