We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Is it possible to validate prinulitelno cause specific cells for SfDataGrid

Thread ID:





120138 Sep 3,2015 03:30 PM UTC Sep 8,2015 09:47 AM UTC WPF 5
Tags: SfDataGrid
Asked On September 3, 2015 03:30 PM UTC


I use SfDataGrid in my WPF application.
In this grid i have ComboBox column. And a set of mandatory fields is determined by value in this CommoBox. And row data save button i have in same row in other column, so row validation not be triggered in common case.

Question is:
Is it possible to force the validation call for specific cell? 

Replied On September 3, 2015 03:32 PM UTC

Sorry errors in subject. I cant edit it now.

Replied On September 4, 2015 07:39 PM UTC

I found a solution.

I was hoping to do it with validation through Events, but i was wrong.
Suffice it to implement the INotifyDataError and use CustomValidadionAttribute.
(example: https://anthymecaillard.wordpress.com/2012/03/26/wpf-4-5-validation-asynchrone/)

Medot will look something like this

        public static ValidationResult CustomValidate(object obj, ValidationContext context)
            var itemObject = (ItemModel)context.ObjectInstance;
            if (itemObject .Type ==  ItemType.Type1
                && !itemObject .Property1.HasValue)
                return new ValidationResult(string.Format("Mandatory for type '{0}'", itemObject .Type .GetDescription()), new List<string> { "Property1" });
            if (itemObject .Type !=  ItemType.Type1
                && itemObject .Property1.HasValue)
                return new ValidationResult(string.Format("Not allowed for type '{0}'", itemObject .Type .GetDescription()),  new List<string> { "Property1" });
            return ValidationResult.Success;

Elangovan S [Syncfusion]
Replied On September 7, 2015 06:58 AM UTC

Hi Vladimir,
Sorry for the delayed response,
Yes, it’s possible to validate the specific cell, by setting the GridValidationMode. GridValidationMode is the dependency property that switches between the modes of validations. The validation modes are as follows.
None: Disables the validations by Data Annotations and also by underlying Data implementations such as IDataErrorInfo or INotifyDataErrorInfo. By default, GridValidationMode is set to ‘None’.
InEdit: Enables the validations and displays the error information in the corresponding cell. You cannot shift the focus to other row.
InView: Enables the validations and displays the error information in the corresponding cell. Also, you can shift the focus to other cells to view the error information.
For more details, you can download the sample from the following location.
UG Link:
Please let us know if you have any more query,
Elangovan S

Replied On September 7, 2015 12:20 PM UTC

Thanks for your reply.

I have read the documentation before.
I was interested in revalidation of some fields by another field value changes.
And I was able to get it to implement INotifyDataErrorInfo.

But now I got another error. Could you help me with it?
I call revalidation for all properties in OnPropertyChanged, so i can be sure that all properties of model update error state. But the validation error in messages hint duplicated. Apparently, one takes by grid, the other is sent by property changed.

But with GridTemplateColumn it works fine, as with all other controls in which there is bounded to a properties with validation .
Is it possible to avoid duplication without replace column by GridTemplateColumn with standart controls in template?

And maybe i should create a separate topic for this issue?

Elangovan S [Syncfusion]
Replied On September 8, 2015 09:47 AM UTC

Hi Vladimir,

Thanks for your update,

Could you please update the replication procedure or sample for revalidation? We cannot understand your replication procedure in which scenario your issue is reproducing for revalidation.

Elangovan S


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon