EnableLoadOnDemand (WebService) and MarkFirstMatch

3 posts, 0 answers
  1. Byzza
    Byzza avatar
    8 posts
    Member since:
    Jul 2007

    Posted 11 Apr 2011 Link to this post

    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. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 15 Apr 2011 Link to this post

    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.

  3. Byzza
    Byzza avatar
    8 posts
    Member since:
    Jul 2007

    Posted 17 Apr 2011 Link to this post

    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

Back to Top