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

Ajax-enable WCF Menu not populating items

2 Answers 63 Views
This is a migrated thread and some comments may be shown as answers.
louis chan
Top achievements
Rank 1
louis chan asked on 26 Jul 2010, 07:41 PM
Hi guys,

According to this help:

I can successfully run OnClientItemPopulatingHandler and there is debug breakpoint that show me GetData is run and the items.count is 4. After that,there is no any radmenu drop-down as expected. Here is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<head runat="server">
    <script type="text/javascript">
        function OnClientItemPopulatingHandler(sender, e) {
            var context = e.get_context();
            //using jQuery to get the checked item and pass it to the server
            context["ProductSuite"] = $telerik.$("input[name='rblSuites']:checked").val();
        function OnClientItemPopulatedHandler(sender, e) {
            var items = e.get_item().get_items();
            for (var i = 0; i < items.get_count(); i++) {
                var item = items.getItem(i);
                //getting the attribute of the item
                var myCustomAttribute = item.get_attributes().getAttribute("MyCustomAttribute");
                //do something with the attribute
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <asp:RadioButtonList ID="rblSuites" runat="server">
           <asp:ListItem Selected="True">ASP.NET AJAX</asp:ListItem>
        <telerik:RadMenu ID="RadMenu1"
               <telerik:RadMenuItem Text="Products" ExpandMode="WebService">
           <WebServiceSettings Method="GetData" Path="../Services/WcfTopMenu.svc" />

<%@ ServiceHost Language="VB" Debug="true" Service="WcfTopMenu" CodeBehind="~/App_Code/WcfTopMenu.vb" %>

svc code behind

Imports System.ServiceModel
Imports System.ServiceModel.Activation
Imports System.ServiceModel.Web
Imports Telerik.Web.UI
<ServiceContract([Namespace]:="")> _
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class WcfTopMenu
    <OperationContract()> _
    Public Function GetData(ByVal item As RadMenuItemData, ByVal context As IDictionary(Of String, Object)) As RadMenuItemData()
        Dim items As New List(Of RadMenuItemData)()
        'use the context to get the selected radio button
        Dim productsSuite As String = context("ProductSuite").ToString()
        'the datasource
        'Dim radControls() As String = New String() {"RadMenu", "RadMenu", "RadTreeView", "RadToolBar"}
        Dim radControls As List(Of [String]) = New List(Of String)() From { _
           "RadMenu", _
           "RadMenu", _
           "RadTreeView", _
           "RadToolBar" _
        For Each radControl As String In radControls
            'Optional: set the attribute of the item which will be used
            'in the OnClientNodePopulated event
            Dim newItem As New RadMenuItemData() With { _
             .Text = String.Format("{0} for {1}", radControl, productsSuite), _
             .Value = radControl, _
             .ImageUrl = "Images/" + radControl + ".gif", _
             .Attributes = New Dictionary(Of String, Object)() From {{"MyCustomAttribute", radControl}}
        Return items.ToArray()
    End Function
End Class

Did I miss sth? If so, please tell me. Thx!

2 Answers, 1 is accepted

Sort by
louis chan
Top achievements
Rank 1
answered on 27 Jul 2010, 02:50 AM
According to "C:\Program Files\Telerik\RadControls for ASP.NET AJAX Q2 2010\Live Demos\App_Code\MenuWcfService.cs"
Is that I need 2 data source to get Hierarchical menu and 2 condition checking to find out the on-demand menu whether contains any sub menu in WCF? Thx!
Telerik team
answered on 30 Jul 2010, 08:23 AM
Hi louis,

Actually there's no need for two datasources and also you should know weather an items has subitems in order to set its ExpandMode. Could you please prepare a simple page demonstrating the issue and send it to us? You should open a support ticket and attach it there. Thanks in advance

the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Asked by
louis chan
Top achievements
Rank 1
Answers by
louis chan
Top achievements
Rank 1
Telerik team
Share this question