. . .
<div>
<div>
@Html.EJS().Grid("Grid").DataSource(ds => ds.Url(@Url.Action("UrlDatasource", "Home")).InsertUrl(@Url.Action("Add", "Home")).UpdateUrl(@Url.Action("Update", "Home")).RemoveUrl(@Url.Action("Remove", "Home")).Adaptor("UrlAdaptor")).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("75").Add();
. . .
col.HeaderText("Manage Records").Width("90").Commands(commands).Add();
}).AllowPaging().ActionBegin("begin").EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).ShowConfirmDialog(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); }).AllowSorting().Toolbar(new List<string>() {"Add", "Delete","Search" }).Render()
</div>
</div>
<script>
function begin(args) {
if (args.requestType == "save" && args.action == "add") {
for (var i = 0; i < this.columns.length; i++) {
if (this.columns[i].field == "CustomerID") {
this.columns[i].visible = false;
}
}
}
if (args.requestType == "beginEdit" || args.requestType == "add") {
for (var i = 0; i < this.columns.length; i++) {
if (this.columns[i].field == "CustomerID" && !this.columns[i].visible) {
this.columns[i].visible = true;
}
}
}
}
|