@Html.EJ().Button("mute").Size(ButtonSize.Large).ShowRoundedCorner(true).ClientSideEvents(e => e.Click("click")).Text("Mute") @(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowPaging()
.ClientSideEvents(eve => { eve.ActionComplete("actionComplete"); })
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
col.Type("checkbox").HeaderText("check").Width(90).Add();
})
)
<script>
var primaryKeyValuesArray = [];
function click(args) {
var selectedData = primaryKeyValuesArray; // array of primary key values
$.ajax({
// pass to controller
});
}
function actionComplete(args) {
if (args.requestType == "paging") {
var data1 = this.model.selectedRecords, len1 = data1.length, arrayLength = primaryKeyValuesArray.length;
for (i = 0; i < len1; i++) {
var value = data1[i]["OrderID"]; // orderID is primarykey column field
primaryKeyValuesArray.push(value);
console.log(primaryKeyValuesArray);
}
}
} </script> |