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

MarkFirstMatch and ShowMoreResultsBox

7 Answers 287 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Michael Miller
Top achievements
Rank 1
Michael Miller asked on 02 Jun 2009, 12:29 PM

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.

7 Answers, 1 is accepted

Sort by
0
codedragon
Top achievements
Rank 1
answered on 09 Jun 2009, 04:50 PM
Any updates on this question. I would also like to know the solution.
0
dstj
Top achievements
Rank 1
answered on 09 Jun 2009, 09:36 PM
Hi,

I'm having the exact same problem with v2009.1.527.35. I'm eager for the solution too.
0
Simon
Telerik team
answered on 17 Jun 2009, 08:05 AM
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.
0
Michael Miller
Top achievements
Rank 1
answered on 17 Jun 2009, 06:05 PM

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?

0
Accepted
Simon
Telerik team
answered on 23 Jun 2009, 10:33 AM
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.
0
Michael Miller
Top achievements
Rank 1
answered on 24 Jun 2009, 01:31 PM
Works great. Thanks for your help.
0
ColinBowern
Top achievements
Rank 1
answered on 07 Apr 2010, 07:39 PM
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; 
    } 
}  

Tags
ComboBox
Asked by
Michael Miller
Top achievements
Rank 1
Answers by
codedragon
Top achievements
Rank 1
dstj
Top achievements
Rank 1
Simon
Telerik team
Michael Miller
Top achievements
Rank 1
ColinBowern
Top achievements
Rank 1
Share this question
or