0
votes

I have a Kendo Grid with multi select checkboxes.(Select one by one or select all ).When i click select all or select oney by one i need to take the Id of the selected rows.

In my program multiple selection is ok.But i have no idea how to get selected Id's to the MVC Controller side.

I want to get a Selected NewsId list to the MVC controller

My Kendo Grid

@model TVT.Regional.Web.Models.ViewModel<NEWS.Current.NewsModel>
 @(Html.Kendo().Grid<NEWS.Current.NewsModel>()
  .Name("NewsGrid")
  .Columns(columns =>
  {
      columns.Bound(x => x.NewsID).Template(@<text></text>).ClientTemplate("<input type='checkbox' class='chkbox' />");
      columns.Template(c => { }).ClientTemplate("<input type='checkbox' id='${NewsID}'  class='chknewsdtl' value='${NewsID}'/>");
      columns.Bound(x=>x.NewsId).Width(80).Title("News Id");
  })

 .Scrollable()
  .Sortable()
  .Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
  .Filterable()
  .Events(events => { events.Change("onRowSelected"); })
  .Pageable(pageable => pageable
  .Refresh(true)
  .PageSizes(true)
  .ButtonCount(5))
  .DataSource(datasource => datasource.Ajax().Read(read => read.Action("GetAllRegionalNews", "NewsController")))
    )

I have perform checkbox multiselect through Javascript.I have a button and button click trigger MVC controller.

My MVC Controller

 public ActionResult RegionalNewsCon(NewsModel mod) // In here i take a NewsModel object,i have no idea is that correct when i get a list of NewsId's
    {
       // Some code here
    }

My Model

public class NewsModel
    {
        public int NewsId { get; set; }
        public string NewsName { get; set; }
        //other properties here
    }
1

1 Answers

1
votes

Explore adding an AJAX update call in your Kendo Grid:

.Datasource(datasource => datasource.Ajax
    .Read(read => read.Action(...))
    .Update(update => update.Update("UpdateAction", "Controller"))

Then in your controller add an Action:

public ActionResult UpdateAction(IEnumerable<NewsModel> model)
{
    //...do stuff
}