New to Telerik UI for ASP.NET Core? Start a free 30-day trial
Sending the Selected Grid Rows to the Controller
Environment
Product Version | 2022.3.913 |
Product | Telerik UI for ASP.NET Core Grid |
Description
How can I get the selected rows in the Telerik UI for ASP.NET Core Grid and send them through an AJAX request to the server?
Solution
- Create a button and handle its
click
event. - Use the client-side
select()
method to get the selected row elements. - Iterate through the selected rows, retrieve the respective data item through the
dataItem()
method of the Grid, and store it in an arrayselectedDataItems
. - Convert the data items into strings by using the
JSON.stringify()
method. - Perform an asynchronous HTTP (Ajax) request to the server.
- Access the received data on the server.
Razor
@(Html.Kendo().Button()
.Name("sendDataBtn")
.Content("Submit selected Grid rows to the server")
.HtmlAttributes(new { type = "button" })
.Events(ev => ev.Click("onClick"))
)
@(Html.Kendo().Grid<GridModel>()
.Name("grid")
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
//Other configuration
)