This is a migrated thread and some comments may be shown as answers.

Selectable Multiple Post

1 Answer 11 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 25 Jan 2014, 06:11 PM
I have a grid where I want to select multiple rows and post back a list of IDs back to an action.  I've tried various ways but I'm not successful.  Here's my code.

@Html.Kendo().Grid(Model).Name("events").Columns(columns =>
    {
        columns.Bound(c => c.EventID).Width(140).Title("Name").Hidden(true);
        columns.Bound(c => c.EventName).Width(140).Title("Name");
        columns.Bound(c => c.EventStatus).Width(120).Title("Status");
        columns.Bound(c => c.EventStartDate).Width(140).Format("{0: MM-dd-yyyy}").Title("Start Date");
        columns.Bound(c => c.EventEndDate).Width(140).Format("{0: MM-dd-yyyy}").Title("End Date");
        columns.Bound(c => c.RegisteredParticipants).Width(120).Title("Registered");
    }).HtmlAttributes(new { style = "height: 400px;" }).Scrollable().Sortable().Selectable(s => s.Mode(GridSelectionMode.Multiple)).DataSource(d => d.Server().Model(m => m.Id(c => c.EventID))
)

//Action 
   [HttpPost]
     public ActionResult EmailEvents(IEnumerable<int> events)
     {

         if (events != null)
         {
             if (events.Any())
             {
                 EmailEventParticipants(events);
             }
         }
         return View();
     }

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 29 Jan 2014, 08:11 AM
Hi Steve,

This behavior could be achieved in the following manner:
  1. Get the selected rows using the select method
  2. Iterate over them and get dataItem corresponding to each row 
  3. Push the IDs of the data items to an array 
  4. Pass the array using an ajax request

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or