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

ContextMenu provider confusion.

1 Answer 57 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Satyaprakash
Top achievements
Rank 1
Satyaprakash asked on 30 Jun 2008, 03:38 PM
Hi,

private

void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)

{

if (e.ContextMenuProvider is GridHeaderCellElement)

{

e.ContextMenu =

this.columnContextMenu;

}

else if(e.ContextMenuProvider is GridDataRowElement )

{

GridDataRowElement cell = (GridDataRowElement)e.ContextMenuProvider;

e.ContextMenu =

this.contextMenu;

}

}



I want to open a context menu when user click any where on a prticular Data row.

I also wants the value of all the column in that row.

Let me know which class will be suitable as a context menu provider so that i get all the data in that row and also be able to open the contextMenu..

Povide an example if possible?


Note :- The code in the else-if part is not working properly.

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 03 Jul 2008, 10:57 AM
Hi Satyaprakash,

I have attached a sample project to demonstrate how to open your custom context menus, depending on the type of cell element, which is clicked.

As to the non-working code in the else if clause, you should not cast e.ContextMenuProvider to GridDataRowElement, but to GridDataCellElement instead:
GridDataCellElement cell = (GridDataCellElement)e.ContextMenuProvider; 

Should you want to take the corresponding row of the clicked cell, get the RowInfo of the e.ContextMenuProvider:
GridViewRowInfo row = ((GridDataCellElement)e.ContextMenuProvider).RowInfo; 

If you have additional questions, do not hesitate to contact me.

Regards,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Satyaprakash
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or