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

Alert needed on losing focus from Editable Rdcombox if text entered does not match

3 Answers 80 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Manishkumar
Top achievements
Rank 1
Manishkumar asked on 15 Nov 2011, 11:02 AM

Hi,


I have radcombobox which is

IsEditable="True" 
IsTextSearchEnabled="True" 
TextSearchMode="StartsWith"

 
Now when user enters some text which is not present in the list that is binded to the radcombobox and the radcombobox loses focus, i want a alert which tells users that value entered is not available and clears the text entered in the radcombobox.

Please guide.

 

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 16 Nov 2011, 09:53 AM
Hi Manishkumar,

Please find attached a simple example which demonstrates how you can implement validation in RadComboBox.

Hope it helps.

All the best,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Manishkumar
Top achievements
Rank 1
answered on 18 Nov 2011, 11:20 AM
Hi Yana,

Thanks for replying.
The example provided is not helping though. I can enter wrong values in the radcombobox and even on losing focus, no alert is thrown to the user.
0
Yana
Telerik team
answered on 21 Nov 2011, 03:18 PM
Hello Manishkumar,

I've modified the XAML from the project to show how to set ErrorTemplate:

<Window.Resources
    <ControlTemplate x:Key="ErrorTemplate">
        <DockPanel LastChildFill="True">               
            <TextBlock DockPanel.Dock="Top"
                        Text="{Binding ElementName=comboBox,Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"
                        Foreground="Red"                           
                        FontWeight="Bold"/>
            <Border BorderBrush="Red" BorderThickness="1">
                <AdornedElementPlaceholder Name="comboBox" />
            </Border>
        </DockPanel>
    </ControlTemplate>
</Window.Resources>
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="100" />
        <RowDefinition Height="50" />
    </Grid.RowDefinitions>
        <telerik:RadComboBox x:Name="comboBox" IsEditable="True" Width="300" Height="22"
                        IsTextSearchEnabled="True"
                        TextSearchMode="StartsWith"
                        ItemsSource="{Binding Items}"
                        SelectedValue="{Binding SelectedItem, Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                        Validation.ErrorTemplate="{StaticResource ErrorTemplate}"       />
        <Button Content="click" Grid.Row="1" Width="50" Height="22" />
</Grid>

Hope this helps.

All the best,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ComboBox
Asked by
Manishkumar
Top achievements
Rank 1
Answers by
Yana
Telerik team
Manishkumar
Top achievements
Rank 1
Share this question
or