≺ back to sample list
validation icon
Validation
The Datagrid allows you to provide custom validation rules. This sample explains how.
What is shown in this sample:

Shows how to activate validation on columns after edit. Also shows how to use and override default validation rules(required, range and length), how to provide custom validation rules and validating a column's cell value based on another column cell value. The code makes use of the validationRuleDefinitions property.

The Employee column is using the default "required" and "length"(minimum of 5 characters) validationRules. The Product column is using the default "required" validationRule. The Quantity column is using the default "range" validationRule and overrides the default errorMessage when the value is not between 1 and 400. The Price column is using a custom validationRule to make sure the value is greater than 0. The Stock Level column is using the default "range" validationRule to make sure the value is between 10% and 90%. The Weight column is using a custom validationRule to make sure the value is greater than 0 and overrides the errorMessage. The OrderDate and ShipDate columns are using a custom validationRule to make sure the OrderDate precedes the ShipDate.