Content-Length: 128572 | pFad | http://www.telerik.com/aspnet-core-ui/documentation/html-helpers/datasource/crud

ASP.NET Core Data Source CRUD Operations - Telerik UI for ASP.NET Core
New to Telerik UI for ASP.NET CoreStart a free 30-day trial

Crud Operations

Model.Id is required for the proper execution of Update, Create and Destroy.

Read

The Read method sets the action method which is responsible for reading data items and for returning them as JSON.

Razor
    @(Html.Kendo().DataSource<ProductViewModel>()
        .Name("dataSource1")
        .Ajax(dataSource => dataSource
            .Read(read => read.Action(/* action */"Products_Read", /* controller */"Home"))
        )
    )

Create

The Create method sets the action method which is responsible for saving new data items.

Razor
    @(Html.Kendo().DataSource<ProductViewModel>()
        .Name("dataSource1")
        .Ajax(dataSource => dataSource
            .Model(model => model.Id(product => product.ProductID))
            .Create(create => create.Action(/* action */"Products_Create", /* controller *"Home"))
            .Read(read => read.Action("Products_Read", "Home"))
        )
    )

Update

The Update method sets the action method which is responsible for saving updated data items.

Razor
    @(Html.Kendo().DataSource<ProductViewModel>()
        .Name("dataSource1")
        .Ajax(dataSource => dataSource
            .Model(model => model.Id(product => product.ProductID))
            .Update(update => update.Action(/* action */"Products_Update", /* controller */"Home"))
            .Read(read => read.Action("Products_Read", "Home"))
        )
    )

Destroy

The Destroy method sets the action method which is responsible for destroying data items.

Razor
    @(Html.Kendo().DataSource<ProductViewModel>()
        .Name("dataSource1")
        .Ajax(dataSource => dataSource
            .Model(model => model.Id(product => product.ProductID))
            .Destroy(destroy => destroy.Action(/* action */"Products_Destroy", /* controller*/ "Home"))
            .Read(read => read.Action("Products_Read", "Home"))
        )
    )

Batch Operation

The Batch method configures the batch create, update and destroy operations. This means that all changes are kept on the client until a data source sync() occurs either programmatically or via a Save Changes button click in the grid for example. By default, the batch operations are disabled.

Razor
    @(Html.Kendo().DataSource<ProductViewModel>()
        .Name("dataSource1")
        .Ajax(dataSource => dataSource
            .Batch(true)
            .Model(model => model.Id(product => product.ProductID))
            .Update(update => update.Action("Products_Update", "Home"))
            .Read(read => read.Action("Products_Read", "Home"))
        )
    )

See Also









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://www.telerik.com/aspnet-core-ui/documentation/html-helpers/datasource/crud

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy