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

filtering question

6 Answers 128 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
matt
Top achievements
Rank 1
matt asked on 16 Oct 2008, 05:57 PM
hello,

i am just starting to use the filtering feature of the RadComboBox. i like it.

but it seems that to use it, you must set AllowCustomText to true (so they can type). thats fine. but, if the user is unable to find a ListItem from their text, and they blur the focus, i feel the RadCombBox should reset its text-input area to an empty string.

this way, if theres a RequiredFieldValidator attached to the RadCombBox, it will flag the box as still being empty. currently, it doesnt (since the left over filter text is still in it).

is the only way to handle this for me to write a javascript function that clears the text-input area, attached to the OnClientBlur event?


thanks!
matt

6 Answers, 1 is accepted

Sort by
0
matt
Top achievements
Rank 1
answered on 20 Oct 2008, 04:00 PM
telerik,

any input on this? if the free-form text isnt a match for one of the ListItems, whats the best way to clear it on blur (so RequiredFieldValidators will properly flag it?


thanks,
matt
0
Serrin
Top achievements
Rank 1
answered on 20 Oct 2008, 08:54 PM
Hey Matt,

You shouldn't have to set AllowCustomText to true, I have it on false (see below) and it is working fine.  If they start typing and it filters down to an item, if you don't select that item (i.e. change focus) the combobox reverts back to the previously selected item. So the only options available are those you defined for the combo.

<telerik:RadComboBox ID="RadComboBox1" runat="server" Filter="Contains"   
    MarkFirstMatch="True">  
    <Items> 
        <telerik:RadComboBoxItem runat="server" Text="Cow" Value="Cow" /> 
        <telerik:RadComboBoxItem runat="server" Text="Chicken" Value="Chicken" /> 
        <telerik:RadComboBoxItem runat="server" Text="Chrimp" Value="Chrimp" /> 
        <telerik:RadComboBoxItem runat="server" Text="Dog" Value="Dog" /> 
        <telerik:RadComboBoxItem runat="server" Text="Cat" Value="Cat" /> 
        <telerik:RadComboBoxItem runat="server" Text="Banana" Value="Banana" />  
    </Items> 
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
</telerik:RadComboBox> 

Are you not getting the same functionality?  If not, would you mind posting code so we can help to try and debug it?
0
oVan
Top achievements
Rank 2
answered on 21 Oct 2008, 08:39 AM
This doesn't work for me.
* I type the first characters of an item in the combobox
* The combobox correctly marks the corresponding item
* Instead of clicking on it or pressing Enter, I click outside the combobox to cancel my selection
* Result: the combobox collapses but shows the highlighted item without changing the selectedvalue and without returning to the original text.
<telerik:RadComboBox ID="combo_Projects" DataSourceID="linq_Projects" AppendDataBoundItems="true" 
    AutoPostBack="true" Skin="Vista" DataTextField="ProjectTitle" DataValueField="ProjectID" AllowCustomText="false" 
    Width="250" MarkFirstMatch="true" Font-Bold="true" runat="server" OnSelectedIndexChanged="combo_Projects_SelectedIndexChanged" 
    OnPreRender="combo_Projects_PreRender">  
    <Items> 
        <telerik:RadComboBoxItem Text="(select project)" Selected="true" Value="" /> 
    </Items> 
</telerik:RadComboBox> 
 
0
Serrin
Top achievements
Rank 1
answered on 21 Oct 2008, 01:59 PM
Hmm, without having your Prerender or Selectedindexchanged functions, this is a mockup I made based on your code:

    <telerik:RadComboBox ID="combo_Projects"    
    AutoPostBack="true" Skin="Vista" AllowCustomText="false"    
    Width="250" Font-Bold="true" runat="server" MarkFirstMatch="true">     
    <Items>    
        <telerik:RadComboBoxItem runat="server" Text="Cow" Value="CowA" /> 
        <telerik:RadComboBoxItem runat="server" Text="Chicken" Value="ChickenA" /> 
        <telerik:RadComboBoxItem runat="server" Text="Chrimp" Value="ChrimpA" /> 
        <telerik:RadComboBoxItem runat="server" Text="Dog" Value="DogA" /> 
        <telerik:RadComboBoxItem runat="server" Text="Cat" Value="CatA" /> 
        <telerik:RadComboBoxItem runat="server" Text="Banana"   
            Value="BananaA" /> 
    </Items>    
    </telerik:RadComboBox>    
    <br /> 
        <telerik:RadTextBox ID="RadTextBox1" runat="server">  
        </telerik:RadTextBox> 

With this single line in the page load code-behind (so whenever it posts back from the combo auto-postback I am grabbing the selected value and index):

        RadTextBox1.Text = combo_Projects.SelectedValue.ToString() + " -- " + combo_Projects.SelectedIndex.ToString();  
 

This is showing that the value and index both change when you click off the ComboBox as well as when you make a selection...  Now, without knowing exactly what you're looking for, I tested with a regular dropdown list and with the auto-postback it is showing the exact same behavior (once you type to select it treats it as if you are selecting the item, so even if you click off to something else it's getting that postback).  My best guess would be to turn off the auto-postback and manually force a postback from something else (button, etc).  Not sure if this works for what you're doing though, just taking a stab at it. ;D
0
oVan
Top achievements
Rank 2
answered on 21 Oct 2008, 02:13 PM
@Serrin
The prerender event contains functionality to prefilter the combobox if a specific querystring parameter is present.
The selectedindexchanged event just rebinds a grid on the page, with the grids filterexpression constructed in the pageload event.

The problem with all this is that it's not possible to cancel after you've typed some characters, other than to wipe out whatever you've typed. Even when you press the Esc button, it selects what you've already highlighted by that time. You have to press Esc twice.

This is not logical in UI design.

Thanks for your mockup & efforts...
0
matt
Top achievements
Rank 1
answered on 21 Oct 2008, 05:44 PM
serrin,

unless im doing something weird, you do indeed need to set AllowCustomText in order to make use of the new filter property, which allows one to filter down result based on *any* word, not just the first word's characters. like so:

<Telerik:RadComboBox ID="rcbSignals" 
  DataValueField="SignalTypeID"  
  DataTextField="Code"  
  Width="230"  
  DropDownWidth="400"  
  MarkFirstMatch="true"  
  HighlightTemplatedItems="true" 
  Filter="Contains"  
  AllowCustomText="True" \> 


matt
Tags
ComboBox
Asked by
matt
Top achievements
Rank 1
Answers by
matt
Top achievements
Rank 1
Serrin
Top achievements
Rank 1
oVan
Top achievements
Rank 2
Share this question
or