@Button
<input type="button" value="GetSelectedRecords" id="SelectedRecords" />
@Grid
@(Html.EJ().Grid<OrdersView>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowPaging()
.ClientSideEvents(eve =>
{
eve.ActionBegin("actionBegin");
eve.DataBound("dataBound");})
.Columns(col =>
{
col.Type("checkbox").Width(50).Add();
. . .
}))
@dataBound
function dataBound(args) {
this.model.records = {}; /* Additional property*/
}
@actionBegin
function actionBegin(args) {
if (args.requestType == "paging") {
if (this.selectedRowsIndexes.length > 0)
this.model.records[args.previousPage] = this.getSelectedRecords(); //Store the selected records
}
}
@Button function
$("#SelectedRecords").ejButton({ click: "getMergedSelected" });
function getMergedSelected() {
var obj = $("#FlatGrid").ejGrid("instance");
var r = obj.model.records, selected = [];
for (var p in r) {
ej.merge(selected, r[p]);
}
ej.merge(selected, obj.getSelectedRecords());
return selected;// All selected records
}
|