New to Telerik UI for ASP.NET Core? Download free 30-day trial

Custom validator editing

Loading Demo...
  • EXAMPLE
  • VIEW SOURCE
  • Edit in Theme Builder
  • editing_custom_validation.cshtml
  • Editing_Custom_ValidationController.cs
  • ProductService.cs
  • CustomValidationProductViewModel.cs

Also available for:

API REFERENCE

Description

In numerous scenarios there is a requirement to not only visualize data in a table structure, but also to edit and validate it before save changes.

The Telerik for ASP.NET Core DataGrid helper supports CRUD data editing operations via a simple configuration of its data source. All you have to do to enable its data editing capabilities is to:

  • Set the grid's editable configuration option: .Editable(editable => editable.Mode(GridEditMode.InLine))
  • Specify a unique field in the Model as the DataSource Model Id
  • Configure the DataSource for performing CRUD data operations defining its Read, Create, Update and Destroy actions
  • To enable the Edit command on each row insert a new column: columns.Command(command => { command.Edit(); });

When the ASP.NET Core Grid is put in edit mode, a Kendo UI Validator is automatically enabled and ready to apply rules to the currently edited model or field in accordance with the HTML attributes in the form. The validation rules which are part of ASP.NET Core will be automatically inserted as attributes from the CustomValidationProductViewModel - such as the [Required] attribute. However, when a special rule is required, use the approach as shown in the script below.

In this demo you can see how to extend the built-in Kendo UI Validator with a custom rule.

The sample demonstrates a check for the first capital letter for the ProductName column, when you edit the value in it.



More about the client-side Kendo UI Validator

More about theTelerik Grid for ASP.NET Core

Support & Learning Resources