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

RadComboBox IsEditable=true DataValidation

3 Answers 17 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Vincent asked on 02 Dec 2013, 08:43 AM
Hi, 

I use radComboBox with property IsEditable="True"; 
My problem is, i don't know how i can do validation, i would like to inform user, that city does not exist in the name he write is not in ListCity in my ViewModel.

<telerik:RadComboBox Grid.Column="1" HorizontalAlignment="Stretch" Margin="5,5,0,5" Width="auto"
IsEditable="True"
ItemsSource="{Binding ListCity, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"                                              
DisplayMemberPath="City"
Text="{Binding Person.IdCity, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay}"
SelectedValuePath="IdCity" />

In my ViewModel, i have :

private ObservableCollection<TableCity> _listCity;
 
public ObservableCollection<TableCity> ListCity
        {
            get { return this._listCity; }
            internal set { Set<ObservableCollection<EntiteVille>>("TableCity", ref _listCity, value); }
        }

In my class Person i have :

protected override void GetValidationError(string propertyName, ref string strErrorMsg)
        {
            switch (propertyName)
            {
                    case "IdCity":
                    if (this.IdCity== null) strErrorMsg = "Ce param├Ętre est obligatoire";
                    break;

When i use, RadMaskedTextInput, i do all validation with method GetValidationError, i check property, but here i don't know how i can check the name of the city(string)...

Thanx for help, have a good day, Regards, Vincent

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 04 Dec 2013, 11:11 AM
Hi Vincent,

Please check our ComboBox DataValidation example here - it shows how you could implement validation in RadComboBox using IDataErrorInfo interface.

I hope this helps.

Regards,
Yana
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Vincent
Top achievements
Rank 1
answered on 04 Dec 2013, 11:39 AM
Thx Yana,

I had already check this exemple but it does'nt help me!

I check dataValidation of my combobox in class person with property IdCity but the property i want to check is City(name of city) in my Class City.

in fact, i don't want to do ValidatesOnDataErrors with selectedValue, but with DisplayMemberPath...

I hope it's enought understandable..

Regards, Vincent.
0
Yana
Telerik team
answered on 10 Dec 2013, 10:40 AM
Hi Vincent,

As far as I can see the validation is set on the Text of the ComboBox which actually is the text of the input field and it is set to the property assigned to the DisplayMemberPath.

However,  if you do not set SelectedValuePath, SelectedValue will be of type TableCity ( as the ItemsSource is set to a collection of TableCity objects), so you can implement the validation on SelectedValue and in the validation method check the needed property.

I hope this helps.

Regards,
Yana
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ComboBox
Asked by
Vincent
Top achievements
Rank 1
Answers by
Yana
Telerik team
Vincent
Top achievements
Rank 1
Share this question
or