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

MarkFirstMatch

1 Answer 147 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 25 Oct 2010, 03:44 PM
Here my combo box:

<

 

 

telerik:RadComboBox ID="rcbItemName" runat="server" AllowCustomText="True" CausesValidation="False" MarkFirstMatch="True" />

 



I am allowing the customer type in the itemname.  If the itemname exist it mark the first match.     That works good. 
I also what the customer to be able to enter a itemname that is not in the dropdown list.  That works good.

Is there a way for the dropdown box to close once the itemname does not match anything in the drop down list?  I look at the demo and it does not close when an item is not match.

Thanks,
David

1 Answer, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 01 Nov 2010, 02:05 PM
Hello David ,

I am afraid that the behaviour that you describe is not officially supported.

You can try attaching an onkeyup event handler to RadComboBox input at client-side page load.
Then after user types a text at control input simply check if there is a RadComboBox item with such text and  close the dropdown.
<script type="text/javascript">
 
    function pageLoad() {
        var combo = $find("<%=rcbItemName.ClientID %>");
        var input = combo.get_inputDomElement();
        input.onkeyup = onKeyUpHandler;
    }
 
 
    function onKeyUpHandler(e) {
 
        var combo = $find("<%=rcbItemName.ClientID %>");
        var comboText = combo.get_text();
        var item = combo.findItemByText(comboText);
        if (item == null && comboText != "") {
 
            combo.hideDropDown();
        }
        else if (e.keyCode == 8) {
            if (!combo.get_dropDownVisible())
                combo.showDropDown();
        }
    }
</script>
 
<telerik:RadComboBox ID="rcbItemName" runat="server"
    AllowCustomText="True" CausesValidation="False"
    MarkFirstMatch="True" />

I hope this helps.

All the best,
Kalina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
David
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or