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

Display RadContextMenu only at specific column

5 Answers 115 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 06 Sep 2011, 09:01 AM
Hi,

I have a context menu in RadGridView:

                    <telerik:RadContextMenu.ContextMenu>
                        <telerik:RadContextMenu x:Name="radContextMenu"
                                         Opened="RadContextMenu_Opened">
                            <telerik:RadMenuItem Header="{Binding MoveUpCommand.Text}"
                                          Command="{Binding MoveUpCommand}" />
                            <telerik:RadMenuItem Header="{Binding MoveDownCommand.Text}"
                                          Command="{Binding MoveDownCommand}" />
                            <telerik:RadMenuItem Header="{Binding StartNextAction.Text}"
                                                 Command="{Binding StartNextActionCommand}">
                                <nav:RadMenuItem.Icon>
                                    <Image Source="/MyApp;component/Images/Buttons/gear_shifbutton.png" Width="16" Height="16" />
                                </nav:RadMenuItem.Icon>
                            </telerik:RadMenuItem>
                        </telerik:RadContextMenu>
                    </telerik:RadContextMenu.ContextMenu>

and I want display it only at specific datacolumn. Is it possible? I haven't found any example related to this problem.

I'm using I'm using 2010.1.603.1040

Best regards

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 07 Sep 2011, 07:23 AM
Hi John,

You may try to handle the Opening event of the context menu and cancel it if it is not above the column you want. For example:

private void RadContextMenu_Opening(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadContextMenu contextMenu = sender as RadContextMenu;
            GridViewCell clickedCell = contextMenu.GetClickedElement<GridViewCell>();
            if (clickedCell.Column.UniqueName != "Name")
            {
                e.Handled = true;
            }
        }

 

All the best,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
John
Top achievements
Rank 1
answered on 08 Sep 2011, 01:36 PM
Thanks Maja for you reply,

I haven't "Opening" event in my version of contextmenu and I can't upgrade it to new.

Is there any other way to struggle with it?

Best regards
0
Maya
Telerik team
answered on 08 Sep 2011, 01:50 PM
Hello John,

May you clarify which version of RadControls are you working with ? Why is it not possible for you to upgrade ?
Generally, our recommendation is always to work with the most recent version since you can benefit from all the features we introduce as well as from the bug fixes added. 

 

Greetings,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
John
Top achievements
Rank 1
answered on 08 Sep 2011, 01:56 PM
I'm using I'm using 2010.1.603.1040

Now I can't upgrade because of some dependencies in other controls to your older version.
I'm new in this company, and now I got order, that for next months I must work with those older controls.
0
Maya
Telerik team
answered on 08 Sep 2011, 03:59 PM
Hello John,

You may try to define a ContextMenu similar to this example. In your case, however, you may verify whether the cell (the element returned by GetClickedElemente<T>() method) belongs to the column you want.  
 

All the best,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Maya
Telerik team
John
Top achievements
Rank 1
Share this question
or