@(Html.EJ().Grid<object>("Grid")
.Datasource((IEnumerable<object>)ViewBag.data)
.AllowPaging()
.EnableAutoSaveOnSelectionChange(false)
.PageSettings(page => { page.PageSize(10); })
.EnableRowHover(false)
.EditSettings(edit => { edit.AllowDeleting().AllowEditing().AllowEditOnDblClick(false); })
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(90).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(90).Add();
..
}).ClientSideEvents(eve => eve.ActionBegin("actionbegin")))
<script type="text/javascript">
function actionbegin(args){
if (args.requestType == "beginedit") {
var editbutton = this.element.find(".e-editbutton.e-button");
var deletebutton = this.element.find(".e-deletebutton.e-button");
if (editbutton.length > 1) {
for (i = 0; i < editbutton.length; i++) {
if (i != args.rowIndex) {
editbutton.eq(i).addClass("e-disable");
deletebutton.eq(i).addClass("e-disable");
}
}
}
}
}
</script> |