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

2 X ContextMenu with 1 X Grid = ???

2 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 18 May 2011, 08:46 PM
Hi

I have a little problem. I have a grid and I want to show a context menu when I click inside the grid, but if I click on a row of the grid, I want to show the context menu A and if I click in the grid, but not on a row, I want to show the context menu B. For doing that, I tried to make a context menu for when I click on a row and I created another context menu who target the entire grid. So, it okay when I don't click on a row, but when I do, two context menu appears and it's the wrong that stay. May someone help me with this ? Thanks.

2 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 24 May 2011, 10:07 AM
Hello David,

Thank you for contacting us.

To achieve the desired functionality you could try handling the OnClientShowing of both ContextMenus. In the first handler you could set some flag to true and into the second handler you could check if this flag is true. If it is true then you could cancel the opening the second ContextMenu. For example:
<telerik:RadCodeBlock runat="server">
        <script type="text/javascript">
            var shouldCancelShowing = false;
            function OnClientShowing1(sender, eventArgs) {
                shouldCancelShowing = true;
            }
            function OnClientShowing2(sender, eventArgs) {
                if (shouldCancelShowing) {
                    eventArgs.set_cancel(true):
                }
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadContextMenu ID="RadContextMenu1" runat="server" OnClientShowing="OnClientShowing1">
        <Targets>
            <telerik:ContextMenuElementTarget ElementID="element" />
        </Targets>
        ...
    </telerik:RadContextMenu>
    <telerik:RadContextMenu ID="RadContextMenu2" runat="server" OnClientShowing="OnClientShowing2">
        <Targets>
            <telerik:ContextMenuElementTarget ElementID="element" />
        </Targets>
        ...
    </telerik:RadContextMenu>

Please give it try and let me know if it helps you. Looking forward for your reply.

Best wishes,
Radoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
David
Top achievements
Rank 1
answered on 24 May 2011, 04:50 PM
Hi,

Really big thanks Radoslav. It works fine. Now, I really feel stupid 'cause the answer was really easy to figure out. 
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
David
Top achievements
Rank 1
Share this question
or