Rad Context Menu using Web Service

1 posts, 0 answers
  1. balaji
    balaji avatar
    69 posts
    Member since:
    May 2009

    Posted 13 Aug 2009 Link to this post

    Hi
    I have a Req where i have two nodes in treeview one is the folder Node and Another one is the Report Node.
    Am Showing two Seperate Context menu for that Diff Node.
    For inst if I click any Folder Node ill get Context menu as follows 1)Create Folder 2)Copy Policies.And Then if i click the Report Node ill get only one Context Menu as 1)Copy Policies.

    I have Tried To use the Web Service and  i  called a Web Service  using OnClientContextMenuShowing event.
    But for Each and Every click i bind the Context Menu from WebService and Then if i click any other node the Previous Context Menu Gets Appended to the Present Node.Which i feel Errorneous .
    You can find the Picturistique info Below.
    Pic1
    pic2

    Here is the Code Below
     <telerik:RadScriptBlock runat="Server" ID="RadScriptBlock1">
                <script type="text/javascript">

    function onClientContextMenuShowing(sender, args) {
                        debugger;
                        var treeNode = args.get_node();
                        var type=treeNode._textElement.title;
                        treeNode.set_selected(true);
                        var menu = args.get_menu();
                      
                       
                        setMenuItemsState(args.get_menu(), treeNode);
                    }


    function setMenuItemsState(menuItems, treeNode) {

                       
                     
                        if (treeNode._textElement.title == 'Folder') {

                            var count = menuItems.get_items().get_count();
                            if (menuItems.get_items().get_count() > 0)
                                return;
                           
                            WebService.LoadFolderitems(null, function(result) {

                                for (var i = 0; i < result.length; i++) {
                                    var item = new Telerik.Web.UI.RadMenuItem();
                                    item.set_text(result[i].Text);
                                   
                                    menuItems.get_items().add(item);
                                   
                                }
                            });
                         
                        }
                        else {
                            if (menuItems.get_items().get_count() > 0)
                                return;
                            WebService.LoadReportitems(null, function(result) {

                                                            for (var i = 0; i < result.length; i++) {
                                                                var item = new Telerik.Web.UI.RadMenuItem();
                                                                item.set_text(result[i].Text);
                                                              
                                                                menuItems.get_items().add(item);
                                                            }
                               
                            });
                        }

     

                       
                       
                       
                    }

    </script>
                </telerik:RadScriptBlock>



    <telerik:RadTreeView ID="Reportview" runat="server" OnNodeExpand="RadTreeview1_NodeExpand"
                                                        OnClientNodeClicked="nodeClicked" OnClientContextMenuItemClicking="onClientContextMenuItemClicking"
                                                        OnClientContextMenuShowing="onClientContextMenuShowing">
                                                        <ContextMenus>
                                                            <telerik:RadTreeViewContextMenu Skin="Outlook" ID="FolderContextMenu" runat="server">
                                                                <WebServiceSettings Method="LoadFolderitems" Path="WebService.asmx" />
                                                                 <WebServiceSettings Method="LoadReportitems" Path="WebService.asmx" />
                                                            </telerik:RadTreeViewContextMenu>
                                                        </ContextMenus>
                                                        <Nodes>
                                                            <telerik:RadTreeNode runat="server" Expanded="True" ExpandMode="ServerSideCallBack"
                                                                Text="Root" Value="/" ImageUrl="~/images/12.gif">
                                                            </telerik:RadTreeNode>
                                                        </Nodes>
                                                    </telerik:RadTreeView>


Back to Top