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

RadComboBox loadondemand resets position when data is fetched.

2 Answers 13 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Leon
Top achievements
Rank 1
Leon asked on 01 Jul 2014, 10:24 AM
Hi.

As stated in the title, the position keeps resetting to the 1st element in the combobox as soon as new data is added to the combobox.  Below is the itemrequested code I use.

Protected Sub cboInstrument_ItemsRequested(ByVal sender As Object, ByVal e As RadComboBoxItemsRequestedEventArgs)
    Try
        Dim oSender As Telerik.Web.UI.RadComboBox = DirectCast(sender, Telerik.Web.UI.RadComboBox)
        oSender.DataValueField = "Name"
        oSender.DataTextField = "Name"
        Dim data As List(Of Instrument)
        If Not String.IsNullOrWhiteSpace(ExchangeComboBox.SelectedValue) Then
            data = GetData(ExchangeComboBox.SelectedValue, e.Text, False)
            Dim itemOffset As Integer = e.NumberOfItems
            Dim endOffset As Integer = Math.Min(itemOffset + ItemsPerRequest, data.Count)
            'e.EndOfItems = endOffset = IIf(data.Count = 1, 0, data.Count)
            e.EndOfItems = endOffset = data.Count
            For i As Integer = itemOffset To endOffset - 1
                oSender.Items.Add(New RadComboBoxItem(String.Format("{0} - {1}", data(i).Symbol, data(i).Name), data(i).ExchangeSymbolKey))
            Next
            e.Message = GetStatusMessage(endOffset, data.Count)
        Else
            Dim endOffset As Integer = 0
            oSender.Items.Add(New RadComboBoxItem("Select an Exchange", Nothing))
            e.Message = GetStatusMessage(endOffset, 0)
        End If
    Catch exc As Exception
        ProcessModuleLoadException(Me, exc)
    End Try
End Sub

Any help will be greatly appreciated.

Regards

2 Answers, 1 is accepted

Sort by
0
Aneliya Petkova
Telerik team
answered on 04 Jul 2014, 10:40 AM
Hello Leon,

In order to assist you in the most efficient way I would kindly suggest you to open a new support ticket and provide us with a simple runnable project which we can inspect and debug.
Could you please check if you get any JavaScript errors in your browser developer tool?
As far as I can see, you set an Integer value to EndOfItems property, but it should be a Boolean value.
Please check the example in this help article in order to see how you can modify the code part with calculating endOffset and setting EndOfItems.
You could also view the source of our RadComboBox LoadOnDemand online demos.

Regards,
Aneliya Petkova
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Leon
Top achievements
Rank 1
answered on 18 Jul 2014, 02:21 PM
Solved.

Turns out the "selectFirstMatch" option moved it to the top of the list if you filter the list.
Tags
ComboBox
Asked by
Leon
Top achievements
Rank 1
Answers by
Aneliya Petkova
Telerik team
Leon
Top achievements
Rank 1
Share this question
or