New to Telerik UI for ASP.NET Core? Download free 30-day trial
ASP.NET Core Grid Custom Editing
- EXAMPLE
- VIEW SOURCE
-
Change Theme
defaultDefault Theme
- Main
- Main Dark
- Nordic
- Ocean Blue
- Ocean Blue A11Y
- Purple
- Turquoise
Bootstrap Theme- Main
- Bootstrap 3
- Bootstrap 3 Dark
- Main Dark
- Nordic
- Turquoise
- Turquoise Dark
- Urban
- Vintage
Material Theme- Main
- Arctic
- Lime Dark
- Main Dark
- Material 2
- Material 2 Dark
- Nova
Classic Theme- Main
- Green
- Green Dark
- Lavender
- Lavender Dark
- Main Dark
- Metro
- Metro Dark
- Moonlight
- Opal
- Opal Dark
- Silver
- Silver Dark
- Uniform
Fluent Theme- Main
- Main Dark
Also available for:
CLIENT-SIDE API HTML HELPER APIDescription
Some scenarios require the ASP.NET Core DataGrid not only visualize data in a table structure, but also to support editing and validation before users save changes.
The Telerik UI for ASP.NET Core Grid allows you to implement CRUD data-editing operations by setting its data source. To enable the data-editing capabilities of the component:
- Set the
Editableconfiguration property of the Grid—.Editable(editable => editable.Mode(GridEditMode.InCell)). - Specify a unique field in the
Modelas theDataSource.Model.Id. - Configure the DataSource of the Data Grid for performing CRUD data operations by defining its
Read,Create,Update, andDestroymethods.
To allow the insertion of new Data Grid records, you need to add the New Record button in the toolbar of the component—.ToolBar(toolbar => toolbar.Create()).
To enable the Delete command on each row, insert a new column—columns.Command(command => { command.Destroy(); });.
This demo shows how to further customize the editor for the Category field which is an object (a complex type). To make sure that the Data Grid uses the custom editor, add the editor to the ~Views\\Shared\\EditorTemplates folder, for example, @(Html.Kendo().DropDownListFor(m => m).
To ensure that the Grid invokes the custom editor:
- Decorate the
modelproperty with theUIHintattribute.[UIHint("ClientCategory")]public CategoryViewModel Category { get; set;} - Specify a default value that will be used initially when an item will be created:
model.Field(p => p.Category).DefaultValue(ViewData["defaultCategory"] as Kendo.Mvc.Examples.Models.CategoryViewModel);
For more information about the editing capabilities, refer to the official Telerik UI for ASP.NET Core Data Grid product documentation on the available data-editing approaches.