DataBinding issue in RadComboBox through WebService

4 posts, 0 answers
  1. Anjan
    Anjan avatar
    2 posts
    Member since:
    Jan 2014

    Posted 02 Nov 2015 Link to this post

    When we binding the data through web service in RadComboBox, web service method is not calling and data is not binding.

    These are my following Code :

    .aspx :

     <script type="text/javascript">
            var cb;
            function cb_onDataBound(pComboboxItem, pDropDownLine) {
                var customAttributes = pComboboxItem.get_attributes();

                pDropDownLine.update(
                    '<span class="column" style="width:50px;">' + pComboboxItem.get_text().truncate(30, '[...]') + '</span>'
                    + '<span class="column" style="width:50px;">' + customAttributes.getAttribute("Company") + '</span>'
                    + '<span class="column" style="width:50px;">' + customAttributes.getAttribute("City") + '</span>'

                );
            }
            function pageLoad(sender, args) {            
                initComboExtensions();
                cb = $find("RadComboBox1");
               
                cb.onDataBound = cb_onDataBound;
            }
           
           
        </script>​

    <telerik:RadComboBox runat="server"
                    ID="RadComboBox1"
                    Skin="Default"
                    Height="200px"
                    Width="200px"
                    DropDownWidth="200px"                
                    ShowMoreResultsBox="true"
                    EnableVirtualScrolling="true"
                    ChangeTextOnKeyBoardNavigation="false"
                    OnClientItemsRequesting="OnClientItemsRequesting"
                    OnClientItemsRequested="OnClientItemsRequested"
                    OnClientDropDownOpening="OnClientDropDownOpening"                                
                    EnableLoadOnDemand="true">
                    <HeaderTemplate>
                        <ul style="list-style: none">
                            <li>
                                <span class="column" style="width: 50px;">ClientID</span>
                                <span class="column" style="width: 50px;">Company</span>
                                <span class="column" style="width: 50px;">City</span>

                            </li>
                        </ul>
                    </HeaderTemplate>
                    <WebServiceSettings Method="GetClientNames" Path="BindComboboxService.asmx" />
                </telerik:RadComboBox>

     

    .asmx :

    [WebMethod]
            public RadComboBoxData GetClientNames(RadComboBoxContext context)
            {
                
                DataTable data = objProjectBL.PopulateClientCombo();
                List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems);
                RadComboBoxData comboData = new RadComboBoxData();
                try
                {

                    int itemsPerRequest = 10;
                    int itemOffset = context.NumberOfItems;
                    int endOffset = itemOffset + itemsPerRequest;
                    if (endOffset > data.Rows.Count)
                    {
                        endOffset = data.Rows.Count;
                    }
                    if (endOffset == data.Rows.Count)
                    {
                        comboData.EndOfItems = true;
                    }
                    else
                    {
                        comboData.EndOfItems = false;
                    }
                    result = new List<RadComboBoxItemData>(endOffset - itemOffset);
                    for (int i = itemOffset; i < endOffset; i++)
                    {
                        RadComboBoxItemData itemData = new RadComboBoxItemData();
                        itemData.Text = data.Rows[i]["ClientID"].ToString();
                        itemData.Value = data.Rows[i]["ClientID"].ToString();
                        itemData.Attributes["Company"] = data.Rows[i]["Company"].ToString();
                        itemData.Attributes["City"] = data.Rows[i]["City"].ToString();
                        result.Add(itemData);
                    }

                    if (data.Rows.Count > 0)
                    {
                        comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString());
                    }
                    else
                    {
                        comboData.Message = "No matches";
                    }
                }
                catch (Exception e)
                {
                    comboData.Message = e.Message;
                }

                comboData.Items = result.ToArray();
                return comboData;
            }​

  2. Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 05 Nov 2015 Link to this post

    Hi,

    I tested the provided code, and after I removed the dependencies to the underlying data layer, the combobox is working properly. I've attached the sample page I used for testing. Could you verify if it's working on your end as well?

    Regards,
    Bozhidar
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Anjan
    Anjan avatar
    2 posts
    Member since:
    Jan 2014

    Posted 05 Nov 2015 in reply to Bozhidar Link to this post

    Hi, 

    It is working your code. But my scenario is different. I need to populate multiple column in RadComboBox. Please help that one.

  5. Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 10 Nov 2015 Link to this post

    Hi,

    In order to help you with your specific scenario, we would need the relevant code. Please send us the modifications needed to the sample I send you, so that we can troubleshoot the exact case.

    Regards,
    Bozhidar
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top