A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.telerik.com/aspnet-core/html-helpers/data-management/grid/editing/custom below:

ASP.NET Core Data Management Grid Editing Overview

New to Telerik UI for ASP.NET Core? Start a free 30-day trial Editing Overview

The Telerik UI for ASP.NET Core Grid component supports create, update, and delete operations (CRUD) with different modes and user experience.

Basics

The Grid CRUD operations rely on the following algorithm:

  1. Users execute Grid commands (Edit, Save, Delete, and more) with the mouse or keyboard.
  2. The DataSource of the Grid triggers the respective Create, Update, or Destroy actions based on the applied data operation.
  3. The changes are handled in the Controller Action methods, and the new, deleted, or edited data item is returned through the response of the request.
  4. The Grid rebinds to display the latest data.
Model Requirements

Adding, deleting, or editing rows in the Grid sets the following requirements on the Grid model:

Edit Modes

The Grid offers the following modes to add and edit rows with a different user experience:

To enable the editing functionality of the Grid:

  1. Set the Editable configuration:

    @(Html.Kendo().Grid<ProductViewModel>()
        .Name("Grid")
        ... 
        .Editable(e => e.Enabled(true))
    )
    <kendo-grid name="grid">
        <editable enabled="true"/>
        
    </kendo-grid>

    The default edit mode is Inline. To use a different edit mode, specify it through the Mode() option:

    @(Html.Kendo().Grid<ProductViewModel>()
        .Name("Grid")
        ... 
        .Editable(e => e.Mode(GridEditMode.PopUp))
    )
    <kendo-grid name="grid">
        <editable enabled="true" mode="popup"/>
        
    </kendo-grid>

    For more information on the available editable configurations, refer to the HtmlHelper API and TagHelper API options.

  2. Specify the Id field in the Model() configuration of the DataSource:

    .Model(model => model.Id(p => p.ProductID))
    <model id="ProductID">
        
    </model>

    The Model method configures the model of the DataSource. For more information, refer to the Model definition documentation.

  3. Declare the endpoints for the desired actions (Create, Update, Destroy):

    .DataSource(dataSource => dataSource
        .Ajax()
        ... 
        .Read(read => read.Action("Read", "Grid"))
        .Create(create => create.Action("Create", "Grid"))
        .Update(update => update.Action("Update", "Grid"))
        .Destroy(destroy => destroy.Action("Destroy", "Grid"))
    )
    <datasource type="DataSourceTagHelperType.Ajax" page-size="20">
        <transport>
            
            <read url="@Url.Action("Read", "Grid")"/>
            <create url="@Url.Action("Create", "Grid")"/>
            <update url="@Url.Action("Update", "Grid")"/>
            <destroy url="@Url.Action("Destroy", "Grid")"/>
        </transport>
    </datasource>
  4. Define an Action method for each operation in the Controller. Intercept the Model instance, save the changes, and return the expected response.

    The following example shows the Update Action method for an Inline or Popup editable Grid set up with Ajax data binding.

    [AcceptVerbs("Post")]
    public JsonResult Update([DataSourceRequest] DataSourceRequest request, ProductViewModel product)
    {
        if (product != null && ModelState.IsValid)
        {
            productService.Update(product);
        }
    
        return Json(new[] { product }.ToDataSourceResult(request, ModelState));
    }

Editing multiple rows at the same time is not supported.

Delete Operation

Delete operations provide the same user experience in all Grid edit modes and require the same configuration:

@(Html.Kendo().Grid<ProductViewModel>()
    .Name("Grid")
    .Editable(settings => settings.DisplayDeleteConfirmation(false))
    ... 
)
    <kendo-grid name="grid">
        <editable enabled="true" confirmation="false"/>
        
    </kendo-grid>

Delete operations can work even if the Grid editing feature is not enabled.

See the delete operations in action in the complete examples for Grid Inline, InCell, and Popup editing. Also, check how to customize the Delete Confirmation Dialog.

Commands

The Grid provides the following built-in commands that enable users to add, delete, and edit rows:

Users execute commands in the following ways:

Command buttons can only reside in Grid column commands or the Grid Toolbar. You can also trigger the desired operation programmatically from anywhere on the page using the client-side methods.

Known Limitations

The following limitations apply when using editing along with other features of the component.

See Also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4