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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Define Validation rules for SfDataGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

145304 Jun 17,2019 07:28 AM UTC Jun 26,2019 06:39 AM UTC WPF 6
loading
Tags: SfDataGrid
Thomas Beimel
Asked On June 17, 2019 07:28 AM UTC

Hi forum,

I would like to set validation rules for the entire data grid or a column.
Is there an example for this?

regards
Thomas

Jagadeesan Pichaimuthu [Syncfusion]
Replied On June 18, 2019 07:16 AM UTC

Hi Thomas, 
  
Thanks for using Syncfusion product. 
  
You can able to validate the data in a column by using DataAnnotation attributes by setting SfDataGrid.GridValidationMode or GridColumn.GridValidationMode property to InEdit or InView. 
  
Please refer the below code example, 
  
<syncfusion:SfDataGrid x:Name="grid" 
                       AutoGenerateColumns="False" 
                       GridValidationMode="InView" 
                       ItemsSource="{Binding UserDetails}"> 
  
  
[Range(10000, 30000, ErrorMessage = "The “Salary” field can range from 10000 through 30000.")] 
public int Salary 
{ 
    get { return salary; } 
    set { salary = value; OnPropertyChanged("Salary"); } 
} 
  
  
You can also validate the cells and rows using CurrentCellValidating and RowValidating events in SfDataGrid. You can refer the below UG and KB links for your further details, 
  
  
  
Regards, 
Jagadeesan 


Thomas Beimel
Replied On June 18, 2019 02:59 PM UTC

Hi Jagadeesan,
thanks for your anwser.
But it is not possible to define validation rules like a textbox?



regards
Thomas

Thomas Beimel
Replied On June 18, 2019 03:03 PM UTC

Here the screen shot missing in my last post.

Attachment: ValidationRule_7f505acc.zip

Shobika Palani [Syncfusion]
Replied On June 19, 2019 01:11 PM UTC

Hi Thomas,  
 
Thanks for your update. 
We have analyzed your query , We regret to inform you that currently we don’t have a support for “Applying validation rules in SfDataGrid”. We have already logged this requirement as feature request in our database. We don’t have any immediate plans to implement this feature. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest.  We will implement this feature in any of our upcoming release. We will let you know when this feature is implemented. We appreciate your patience until then  
 
Please login to view the feedback further,  
 
Also as mentioned in our previous update, You can use custom validation using CurrentCellValidating and RowValidating events or you can use built in validation using IDataErrorInfo/InNotifyDataErrorInfo instead of ValidationRule.  
 
Please refer the below UG link for IDataErrorInfo.  

Regards, 
 
Shobika. 


Thomas Beimel
Replied On June 25, 2019 09:46 AM UTC

Hi,

I got it to work with the INotifyDataErrorInfo.
Thanks for your help.

regards
Thomas

Farjana Parveen Ayubb [Syncfusion]
Replied On June 26, 2019 06:39 AM UTC

Hi Thomas, 
Thanks for the update. 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
Regards, 
Farjana Parveen A 


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.

Please sign in to access our forum

This page will automatically be redirected to the 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

Live Chat Icon For mobile
Live Chat Icon