Load items in Radcombobox on page load

2 posts, 0 answers
  1. Vineet
    Vineet avatar
    2 posts
    Member since:
    Aug 2013

    Posted 13 Aug 2013 Link to this post

    Hi,

    I am using a radcombobox and populating it using webservice. However the combobox is not loaded when the page loads the first time. when i start typing the combobox gets loaded fine with the values. i want the combobox to contain top 100 rows when the page loads so that by just clicking on the dropdown arrow it can see the option with out typing anything in the box.
    Please find my code below:-

    <telerik:RadComboBox runat="server" ID="RadComboBox1" Width="300px" Height="550px" AllowCustomText="true" OnClientItemsRequesting="OnClientItemsRequesting"
                    EnableLoadOnDemand="true" ShowMoreResultsBox="true" EnableVirtualScrolling="true" MarkFirstMatch="true" ItemsPerRequest="100"
                    EnableAutomaticLoadOnDemand="true" AutoPostBack="true">
                    <WebServiceSettings Path="~/Controls/ManagerListService.asmx" Method="GetManagerNames" />
                </telerik:RadComboBox>

    javascript
    function OnClientItemsRequesting(sender, eventArgs) {
            var context = eventArgs.get_context();
        }

    web srevice code

     <WebMethod()>
        Public Function GetManagerNames(context As RadComboBoxContext) As RadComboBoxData
            Dim data As DataTable = Employee.LineManagersForUser(context.Text)

            Dim result As New List(Of RadComboBoxItemData)()
            Dim dropDownData As New RadComboBoxData()
            Dim itemOffset As Integer = context.NumberOfItems
            Dim endOffset As Integer = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count)
            dropDownData.EndOfItems = endOffset = data.Rows.Count

            result = New List(Of RadComboBoxItemData)(endOffset - itemOffset)

            For i As Integer = itemOffset To endOffset - 1
                Dim itemData As New RadComboBoxItemData()
                itemData.Text = data.Rows(i)("Name").ToString()
                itemData.Value = data.Rows(i)("EmplID").ToString()

                result.Add(itemData)
            Next

            dropDownData.Items = result.ToArray()
            Return dropDownData
        End Function


    Thanks,
    Vineet
  2. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 16 Aug 2013 Link to this post

    Hi Vineet,

     
    Thank you for contacting Telerik support.

    You can request the first items on pageLoad as for example it is done in the code below:

    <script type="text/javascript">
               function pageLoad() {
     
                   var combo = $find("<%=RadComboBox1.ClientID%>");
                   combo.requestItems("");
               }
     
           </script>

    Hope this will work for you. if you have further questions please don't hesitate to contact us again.

    Regards,
    Plamen
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top