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

How to return empty menuItem for RadContextMenu

3 Answers 81 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Timothy
Top achievements
Rank 1
Timothy asked on 26 Mar 2009, 08:45 AM
Hi,

I'm using the RadContextMenu passing in parameters in Context to dynamically load options for a Grid in ASP.NET.

In the backend it's calling database to retrieve links the user can do.

The problem is that when there is no links to return, passing a empty RadMenuItemData array causes javascript error in the aspx.

I first try to raise an ApplicationException, and the error message will get displayed as an alert to the user.
However, this approach will somehow make the contextmenu don't call the web service at all (I set a breakpoint at the populate method, and it's not getting called) the next time you right click. If you right click again then it will be back to normal.            

I wonder what's the recommended way to pass empty results so no itemdata will be populated?


Thanks!        

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 26 Mar 2009, 03:12 PM
Hi Timothy,

I tried to reproduce this issue but to no avail. Could you explain in more details and paste some code here so we could test it? Thanks

Best wishes,
Yana
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Timothy
Top achievements
Rank 1
answered on 26 Mar 2009, 05:24 PM
For example,

here is the radcontextmenu:

<telerik:RadContextMenu ID="PopupRadContextMenu" runat="server" Skin="Black" Style="top: 431px;
        left: 206px" OnClientItemPopulating="contextPopulating" OnClientShowing="contextShowing">
        <WebServiceSettings Method="GetActions" Path="/AjaxServices/DashboardService.asmx" />
        <Targets>
            <telerik:ContextMenuControlTarget ControlID="DashboardGridView" />
        </Targets>
        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
        <Items>
            <telerik:RadMenuItem Text="Details" target="RadPane2">
            </telerik:RadMenuItem>
            <telerik:RadMenuItem Text="Actions" ExpandMode="WebService">
            </telerik:RadMenuItem>
        </Items>
    </telerik:RadContextMenu>

And the web service basically just returns a empty collection like :

return new RadMenuItemData[] {};

This causes a JScript error. I have the asp:ScriptManager also in the page.

Another problem I'm having now is that, somehow once the contextMenu loads items from the web service, it doesn't call the web service again as it seems to be cached somewhere. Can I make it so I can call everytime the user wants to expand the node?

Thanks!            


0
Yana
Telerik team
answered on 30 Mar 2009, 01:26 PM
Hi Timothy,

I've attached my test page which demonstrates that returning empty array works without a problem. Please download it and give it a try.

About your second question - actually this is by design, when the items are loaded, their ExpandMode becomes client-side.

Kind regards,
Yana
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Menu
Asked by
Timothy
Top achievements
Rank 1
Answers by
Yana
Telerik team
Timothy
Top achievements
Rank 1
Share this question
or