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

Bind Context Menu to WCF Service

2 Answers 74 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Oleg Medyanik
Top achievements
Rank 1
Oleg Medyanik asked on 06 Oct 2009, 02:13 PM
Hi,
Can i bind context menu to WCF service  and pass some additional parameters to the method.
Exactly as you allow for Grid?

My code is
    <telerik:RadContextMenu ID="StatementMenu" runat="server" Skin="DirectEDI" EnableEmbeddedSkins="false">  
        <WebServiceSettings Path="BCGridService.svc" Method="LoadStatementMenuData" /> 
        <DataBindings> 
            <telerik:RadMenuItemBinding Depth="0" ExpandMode="WebService" /> 
        </DataBindings> 
    </telerik:RadContextMenu> 
but i can't hit breakpoint in WCF service. Is there method to rebind menu data?

My scenario is - when user clicks some link i have to re-bind menu using some id and open context menu.

Thank you

2 Answers, 1 is accepted

Sort by
0
Guo Huang
Top achievements
Rank 1
answered on 20 Oct 2009, 05:37 PM
I am looking for EXACTLY the same solution. i want to bind the whole radcontextmenu using javascript to call the webservice, but i don't see any way to do it. the only example that i found is

            var menu = getObjectByID(id);
            
            for (var i = 0; i < menu.get_items().get_count(); i++)
            {
                var item = menu.get_items().getItem(i);
                item._loadChildrenFromWebService();
            }
        
            menu.show(evnt);

but if there is no items in the menu, it won't populate from webservice.
0
T. Tsonev
Telerik team
answered on 26 Oct 2009, 07:33 AM
Hello,

Currently RadMenu and RadContextMenu support Web Service loading only for sub-items. The root items must be created manually.

Root items can be manipulated on the client-side and you can manually populate them from a WS, but the easier option would be to place them in a sub-item. You can then use the code snippet that Guo posted to preload them if needed.

Passing additional information to the WS is possible using the OnClientItemPopulating event. The context property of the event arguments will be passed to the WS.

There is a help topic that demonstrates how to do this, but with RadMenu:
http://www.telerik.com/help/aspnet-ajax/menu-populate-from-wcf-service.html

One additional thing that you'll need to do is to clear the loaded items when the menu is closed, so they'll be re-populated the next time it's open. You can do this in the OnClientHidden event.

Kind regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Menu
Asked by
Oleg Medyanik
Top achievements
Rank 1
Answers by
Guo Huang
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or