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

get *only* the text that you typed (and that is allowed)

2 Answers 47 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
David asked on 06 Nov 2013, 03:52 PM
i am trying to get the text that i have typed into my radcombobox.

The combobox is defined as :

cmb = New RadComboBox
      cmb.ID = "cmbSearch"
      cmb.ShowDropDownOnTextboxClick = False
      cmb.MarkFirstMatch = True
      cmb.DataTextField = "TextField"
      cmb.DataValueField = "ValueField"
      cmb.ShowToggleImage = False
      ' cmb.AutoPostBack = True
      cmb.Attributes("onkeyup") = "handleKeyPress();"
      If Not Page.IsPostBack Then
          cmb.DataSource = _recipe.getAllStockItems(_security.UserID, _security.DivisionId)
          ViewState("cmbDataSource") = cmb.DataSource
      End If

now, every time i type something into the box, the 'handleKeyPress' javascript function runs - as you can see in the above code.

this javascript function is defined as:

function handleKeyPress()
    var combo = $find('<%=cmb.ClientID%>');
    //  alrt('error');
    document.getElementById('<%=hidAutoComplete.ClientID%>').value = combo._filterText;
 //   alrt('error');
    <%=Page.ClientScript.GetPostBackEventReference(hidAutoComplete, "Change")%>

this is almost ok.
The point that is confusing me is that the 'combo._filterText' gives me my text that i have typed, and this would look like it works.
the radcombobox has an item 'david'. i type in 'da' and the radcomobobx autocompletes it to 'david' but combo._filtertext gives me 'da'.
this is correct and how i would expect it to work.

now, if i typed 'daa' (which doesn't exist in the combobox), the combobox stops me from adding this extra 'a' and will autocomplete it to 'david'.
this is also correct. unfortunately, and this is the problem, 'combo._filtertext' shows 'daa'.

is it possible to get just 'da'. that is, only the text i have entered, and that i am allowed to enter?

2 Answers, 1 is accepted

Sort by
Telerik team
answered on 11 Nov 2013, 03:45 PM
Hello David,

I am afraid, that the desired typed text could not be access using any property or method of the RadComboBox, since the Text of the RadComboBox is automatically set to the first found match. However, you could compare both string ._filterText and .get_text(), in order to capture the matching substrings.

If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Top achievements
Rank 1
answered on 12 Nov 2013, 11:27 AM
that you for your advice.
i have added the following, to give me what I need:

var filtText =  String(combo._filterText);
var fullText = String(combo.get_text());
var actualFilterText = '';
for (var i = 0,len = filtText.length; i < len; i++){
    if (filtText[i].toUpperCase() == fullText[i].toUpperCase()){
        actualFilterText += filtText[i];
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Top achievements
Rank 1
Share this question