How do I get selected rows?

1 Answer 1097 Views
Grid
Mike
Top achievements
Rank 1
Mike asked on 08 Jun 2015, 02:46 AM

I have two grids, one on the left and one on the right. I want to highlight multiple rows in the grid on the left, click a button that says "move", and see the rows added to the grid on the right.

The grid on the left is loaded from an action method, via Ajax. The grid on the right gets data from a JavaScript array of objects.

The part I'm stuck on:

After user clicks the "move" button, how do I get the highlighted rows and loop through them so I can add them to the JavaScript array of objects?

Thanks,

Mike

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 09 Jun 2015, 07:40 AM

Hello Mike,

You should use the dataItem method of the Grid API to get the object associated to that row.
E.g.

var grid = $("#grid").data("kendoGrid");
var selected = [];
grid.select().each(function(){
    selected.push(grid.dataItem(this));
});

Regards,
Dimiter Madjarov
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
Mike
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or