[Index.cshtml]
@(@Html.EJS().Grid<DialogTemplateModel>("DialogTemplateEdit").ActionBegin("actionBegin").DataSource((IEnumerable<object>
)ViewBag.data).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add();
col.Field("EmployeeID").HeaderText("Employee ID").Visible(false).Width("90").Add();
}).AllowPaging().PageSettings(page => page.PageCount(2)).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render())
</div>
<script id="dialogtemplate" type="text/template">
<div id="dialogTemp">
</div>
</script>
<script type="text/javascript">
function actionBegin(args) {
if (args.requestType === "beginEdit" || args.requestType === "add") {
this.columns[2].visible = true; // Enable the visibility for “EmployeeID” column
}
else if (args.requestType === "save") {
this.columns[2].visible = false; // Disable the visibility for “EmployeeID” column
}
}
|