RadComboBox IsEditable=true DataValidation

4 posts, 0 answers
  1. Vincent
    Vincent avatar
    10 posts
    Member since:
    Nov 2013

    Posted 02 Dec 2013 Link to this post

    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
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 04 Dec 2013 Link to this post

    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 >>
  3. DevCraft banner
  4. Vincent
    Vincent avatar
    10 posts
    Member since:
    Nov 2013

    Posted 04 Dec 2013 Link to this post

    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.
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 10 Dec 2013 Link to this post

    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 >>
Back to Top