Bind Context Menu to WCF Service

3 posts, 0 answers
  1. Oleg Medyanik
    Oleg Medyanik avatar
    15 posts
    Member since:
    Sep 2009

    Posted 06 Oct 2009 Link to this post

    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. Guo Huang
    Guo Huang avatar
    6 posts
    Member since:
    Sep 2009

    Posted 20 Oct 2009 Link to this post

    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.
  3. T. Tsonev
    Admin
    T. Tsonev avatar
    2817 posts

    Posted 26 Oct 2009 Link to this post

    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.
Back to Top