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.
Unfortunately, activation email could not send to your email. Please try again.

Is it possible to validate prinulitelno cause specific cells for SfDataGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

120138 Sep 3,2015 11:30 AM Sep 8,2015 05:47 AM WPF 5
loading
Tags: SfDataGrid
Vladimir
Asked On September 3, 2015 11:30 AM

Hello.

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? 


Vladimir
Replied On September 3, 2015 11:32 AM

Sorry errors in subject. I cant edit it now.

Vladimir
Replied On September 4, 2015 03:39 PM

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 02:58 AM

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.
 
Sample:
http://www.syncfusion.com/downloads/support/forum/120138/ze/DataValidationDemo-349409116
 
UG Link:
http://docs.syncfusion.com/wpf/sfdatagrid/data-validation
 
Please let us know if you have any more query,
 
Regards,
Elangovan S

Vladimir
Replied On September 7, 2015 08:20 AM

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 05:47 AM

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.

Regards,
Elangovan S

CONFIRMATION

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.

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.

;