Crud Operations
Model.Idis 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.
@(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.
@(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.
@(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.
@(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.
@(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"))
)
)