MarkFirstMatch and ShowMoreResultsBox

8 posts, 1 answers
  1. Michael Miller
    Michael Miller avatar
    4 posts
    Member since:
    Oct 2006

    Posted 02 Jun 2009 Link to this post

    We have ran into an issue using the radcombobox with ShowMoreResultsbox and MarkFirstMatch properties set to true. After typing the first letter the radcombobox is loads the first 10 items as expected that match the letter typed in, but when the show more results is clicked only one value will be retrieved. It seems the e.text value no longer passes in what was typed, but since the MarkFirstMatch was set to true the first item in the list is passed into e.text.

     

    Is there a way to hold the original value that was passed into the ItemsRequested e.text, instead of the autocompleted value?  We are wanting to still use the MarkFirstMatch.

     

     The issue can be replicated using the Load On Demand Demo and the 103208_sample.zip sample project.  

     

    http://mono.telerik.com/Combobox/Examples/PopulatingWithData/AutoCompleteSql/DefaultCS.aspx

     

    Add a few more companies that start will L into the database.

    Open up the page with the radcombobox.

    Type L.

    After the RadComboBox is loaded, click the show more results button.

    The list will be populated with the first 10 items. However the Summary will show “items 1-1 out of 1.”

     

    Thanks for your help.

  2. codedragon
    codedragon avatar
    1 posts
    Member since:
    Jul 2007

    Posted 09 Jun 2009 Link to this post

    Any updates on this question. I would also like to know the solution.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. dstj
    dstj avatar
    82 posts
    Member since:
    Oct 2006

    Posted 09 Jun 2009 Link to this post

    Hi,

    I'm having the exact same problem with v2009.1.527.35. I'm eager for the solution too.
  5. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 17 Jun 2009 Link to this post

    Hi all,

    Indeed this is the end result of combining the MarkFirstMatch and ShowMoreResults functionalities. 

    You could avoid it by setting MarkFirstMatch to false and handling the client-side ItemsRequested event in this way:

    function onItemsRequested(sender, eventArgs) { 
        if (sender.get_items().get_count() > 0) 
            sender.get_items().getItem(0).highlight(); 

    Is this solution acceptable for you?

    Greetings,
    Simon
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  6. Michael Miller
    Michael Miller avatar
    4 posts
    Member since:
    Oct 2006

    Posted 17 Jun 2009 Link to this post

    I did try the solution, but it did not accomplish what we needed. When the user tabs or clicks off the combobox it will not choose the value that is highlighted, which was why we were using the markfirstmatch. When using Mark first is there a way to separate what is typed and what is highlighted?

  7. Answer
    Simon
    Admin
    Simon avatar
    2281 posts

    Posted 23 Jun 2009 Link to this post

    Hi Michael Miller,

    To futher mimic the MarkFirstMatch functionality you could use the following code:

    function onItemsRequested(sender, eventArgs) { 
        markFirstMatch(sender, function(item) { if (item) item.highlight(); }); 
     
    function onDropDownClosing(sender, eventArgs) { 
        markFirstMatch(sender, function(item) { if (item) item.select(); }); 
     
    function markFirstMatch(comboBox, action) { 
        action(findFirstMatch(comboBox)); 
     
    function findFirstMatch(comboBox) { 
        var text = comboBox.get_text(); 
        if (!text) return null
        var items = comboBox.get_items(); 
        for (var i = 0, length = items.get_count(); i < length; i++) { 
            var item = items.getItem(i);                 
            if (item.get_text().toLowerCase().indexOf(text) == 0) 
                return item; 
        } 

    Please note that you need to handle the DropDownClosing event as well.

    RadComboBox does not differentiate between typed and highlighted text however you could access the text with which the next Items request will be made in the ItemsRequesting event handler.

    I hope this helps.

    Greetings,
    Simon
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  8. Michael Miller
    Michael Miller avatar
    4 posts
    Member since:
    Oct 2006

    Posted 24 Jun 2009 Link to this post

    Works great. Thanks for your help.
  9. ColinBowern
    ColinBowern avatar
    51 posts
    Member since:
    Aug 2012

    Posted 07 Apr 2010 Link to this post

    I had a weird issue where MarkFirstMatch wasn't responding:

    <telerik:RadComboBox ID="Type" runat="server" AccessKey="T" 
        AllowCustomText="false" CollapseAnimation-Type="None" 
        DataTextField="Key" DataValueField="Value" 
        EnableLoadOnDemand="true" ExpandDelay="0" 
        EnableVirtualScrolling="true" ExpandAnimation-Type="None" 
        Filter="Contains" ItemsPerRequest="20" 
        OnClientItemsRequested="onItemsRequested" 
        OnClientDropDownClosing="onDropDownClosing" 
        OnItemsRequested="Type_ItemsRequested" 
        ShowDropDownOnTextboxClick="false" ShowMoreResultsBox="true" 
        Width="100%" meta:resourcekey="Type" /> 

    So I replaced with the code block above modifying it to accept case-insensitive search:

    function findFirstMatch(comboBox) 
        var text = comboBox.get_text().toLowerCase(); 
        if (!text) return null
        var items = comboBox.get_items(); 
        for (var i = 0, length = items.get_count(); i < length; i++) 
        { 
            var item = items.getItem(i); 
            if (item.get_text().toLowerCase().indexOf(text) >= 0) 
                return item; 
        } 
    }  

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017