@(Html.EJ().Grid<object>("Editing")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowSorting()
.AllowPaging()
.EditSettings(edit => { edit.AllowEditing().AllowAdding().AllowDeleting(); })
.Columns(col =>
{
-----------------------------------------
})
.ClientSideEvents(eve => { eve.RowSelected("rowselect"); })
)
--------------------------------------------------
<script>
var select = true;
$(document).on("keydown", function (e) {
if (e.keyCode == 40 || e.keyCode == 38) {
var grid = $("#Editing").ejGrid("instance");
var pageIndex = grid.model.pageSettings.currentPage;
var rowindex = grid.getIndexByRow(grid.getSelectedRows());
rowindex = rowindex + 1;
if (rowindex == grid.model.pageSettings.pageSize && select) {
$("#Editing").ejGrid("getPager").ejPager("goToPage", pageIndex + 1);
grid.selectRows(0);
}
else if (rowindex == 1 && select) {
if (grid.model.pageSettings.currentPage != 1) {
$("#Editing").ejGrid("getPager").ejPager("goToPage", pageIndex - 1);
grid.selectRows(11);
}
}
select = true;
}
});
function rowselect(args) {
if (args.prevRowIndex = this.model.pageSettings.pageSize - 2)
select = false;
}
</script> |