Define Validation rules for SfDataGrid
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
SIGN IN To post a reply.
6 Replies
JP
Jagadeesan Pichaimuthu
Syncfusion Team
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"); }
} |
Sample location: http://www.syncfusion.com/downloads/support/forum/145304/ze/DataValidation1818292926
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
TB
Thomas Beimel
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
TB
Thomas Beimel
June 18, 2019 03:03 PM UTC
SP
Shobika Palani
Syncfusion Team
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.
TB
Thomas Beimel
June 25, 2019 09:46 AM UTC
Hi,
I got it to work with the INotifyDataErrorInfo.
Thanks for your help.
regards
Thomas
FP
Farjana Parveen Ayubb
Syncfusion Team
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
SIGN IN To post a reply.
- 6 Replies
- 4 Participants
-
TB Thomas Beimel
- Jun 17, 2019 07:28 AM UTC
- Jun 26, 2019 06:39 AM UTC