@Grid
@(Html.EJ().Grid<object>("FlatGrid")
.AllowPaging()
.Columns(col =>
{
col.Type("checkbox").Width(70).Add();
. . .
})
.ClientSideEvents(eve=>eve.Create("create").RowSelected("rowSelected").ActionComplete("actionComplete"))
)
//Code example using by your code snippet
@Create event
<script type="text/javascript">
//Create event in Grid
function create(args) {
//Bind the change event for header checkbox
$(".e-checkselectall").change(function () {
var gridObj = $("#Grid").ejGrid("instance"),selectedRecords=gridObj.getSelectedRecords(),len =gridObj.getSelectedRecords().length, rowID=[];
if (len > 0) {
for (var i = 0; i < len; i++) {
var id = selectedRecords[i].OrderID;
var index = rowID.indexOf(id);
if (index > -1) {
rowID.splice(index, 1);
}
else {
rowID.push(id);
}
$("#selectedIds").val(rowID.toString());
}
}
});
}
</script>
//Simplest way to get the primary key field value for single selection or multiple selection
<script type="text/javascript">
//Create event in Grid
function create(args) {
//Bind the change event for header checkbox
$(".e-checkselectall").change(function () {
var gridObj = $("#Grid").ejGrid("instance"),selectedRecords=gridObj.getSelectedRecords(), rowID=[];
rowID = ej.DataManager(selectedRecords).executeLocal(new ej.Query().select("OrderID"));//we can simply get the primary key field values for selected records using Data manager query
});
}
}
</script> |
@Grid
@(Html.EJ().Grid<object>("FlatGrid")
.AllowPaging()
.Columns(col =>
{
col.Type("checkbox").Width(70).Add();
. . .
})
.ClientSideEvents(eve=>eve.Create("create").ActionComplete("actionComplete"))
)
//Code example using by your code snippet
@action complete event
function actionComplete(args) {
if (args.requestType == "paging") {
var selectedRecords = this.getSelectedRecords(), len = this.getSelectedRecords().length, rowID = [];
if (len > 0) {
for (var i = 0; i < len; i++) {
var id = selectedRecords[i].OrderID;
var index = rowID.indexOf(id);
if (index > -1) {
rowID.splice(index, 1);
}
else {
rowID.push(id);
}
$("#selectedIds").val(rowID.toString());
}
}
}
}
//Simplest way to get the primary key field value for single selection or multiple selection
<script type="text/javascript">
function actionComplete(args) {
if (args.requestType == "paging") {
var selectedRecords = this.getSelectedRecords(),rowID = [];
rowID = ej.DataManager(selectedRecords).executeLocal(new ej.Query().select("OrderID"));//we can simply get the primary key field values for selected records using Data manager query
}
}
</script> |