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

EnableLoadOnDemand (WebService) and MarkFirstMatch

2 Answers 79 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Byzza
Top achievements
Rank 2
Byzza asked on 12 Apr 2011, 03:42 AM
I have 2 combo box's on my page using Load on Demand from Webservices which are working great, but I'm trying to enable "MarkFirstMatch", but if I do that the item isn't being selected, but just the text value is being set.
(if they key down to the value, or select with the mouse it works fine, just not when using mark first).

Result
Selectedindex = -1
SelecteItem = Nothing
Selected Value = ""
text = marked FirstMatch.

While I think i could do a work around and do a reverse lookup if value = "' and text = something, I would like to get it working so I can just reference the selectedvalue.

Thanks in advance for any help you can give.

Combo:

<telerik:RadComboBox ID="rcbInitiated" runat="server" DataTextField="userName" MarkFirstMatch="true"
          DataValueField="eID" EnableLoadOnDemand="true" EnableAutomaticLoadOnDemand="true"
         ShowMoreResultsBox="false" EnableVirtualScrolling="false" OnClientDropDownClosed="OnClientDropDownClosed" EnableItemCaching="true">
        <CollapseAnimation Duration="200" Type="OutQuint" />
        <WebServiceSettings Path="~/ws/wsCFR.asmx" Method="GetEIDUserName" />
</telerik:RadComboBox>

WebService:
<WebMethod()> _
Public Function GetUserIDUserName(ByVal context As RadComboBoxContext) As RadComboBoxData
    Return GetItems(context, "userID")
End Function
Public Function GetItems(ByVal context As RadComboBoxContext, ByVal valueField As String) As RadComboBoxData
    Dim data As DataTable = GetData(context.Text)
    Dim comboData As New RadComboBoxData()
    Dim itemOffset As Integer = context.NumberOfItems
    Dim endOffset As Integer = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count)
    comboData.EndOfItems = endOffset = data.Rows.Count
    Dim result As New List(Of RadComboBoxItemData)(endOffset - itemOffset)
    For i As Integer = itemOffset To endOffset - 1
        Dim itemData As New RadComboBoxItemData()
        itemData.Text = data.Rows(i)("userName").ToString()
        itemData.Value = data.Rows(i)(valueField).ToString()
        result.Add(itemData)
    Next
    comboData.Message = GetStatusMessage(endOffset, data.Rows.Count)
    comboData.Items = result.ToArray()
    Return comboData
End Function

2 Answers, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 15 Apr 2011, 08:38 AM
Hi Byzza,

When LoadOnDemand is used you could get the SelectedValue or the Text of the RadComboBox on server-side. What seems strange in your scenario is the fact that you have both LoadOnDemand and AutomaticLoadOnDemand set.

AutomaticLoadOnDemand is used when you want to bind your combobox to a data source without writing any code. Since you are using WebService there is no point of it. Also you are declaring DataTextField and DataValueField both from the markup and in the code behind.

I've prepared an example web site based on your RadCombobox declaration.On post-back the SelectedValue and Text are displayed in two labels.

Please check if you experience the same problem on the test web site provided.

All the best,
Dimitar Terziev
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Byzza
Top achievements
Rank 2
answered on 18 Apr 2011, 03:23 AM

Hi,
Thanks for the example.  After compairing it with mine I found that i had this line:

 

 

sender.clearItems();

 

 

 

In my  OnClientDropDownClosed(sender, args)  Function.

I'm not sure which example I got that line from, but by removing it from my code the dropdowns now appear to work.

The reason for both LoadOnDemand and AutomaticLoadonDemand was just me testing with each as i wasn't sure what each did.  I was orginally only using LoadOnDemand.

I've also removed the DatatextField and DataValueField from the markup, but this didn't affect anything.

Thank you for you help
Regards
Byron

Tags
ComboBox
Asked by
Byzza
Top achievements
Rank 2
Answers by
Dimitar Terziev
Telerik team
Byzza
Top achievements
Rank 2
Share this question
or