- Home
- Forum
- ASP.NET MVC - EJ 2
- Add column in edit dialog form
Add column in edit dialog form
Hi, I have a grid with 9 columns, 3 of them with .visible(false). I need that those 3 columns, shows up in the edit dialog (dialog mode, not dialog template mode).
Thanks for your help.
Kind regards,
Juan J.
SIGN IN To post a reply.
3 Replies
TS
Thavasianand Sankaranarayanan
Syncfusion Team
March 1, 2019 06:16 AM UTC
Hi Juan,
Greetings from Syncfusion.
Based on your query we found that you want to add/edit the invisible columns in Grid without using the dialog template edit in Grid. we can achieve your requirement using the actionBegin event of Grid.
Refer the below code example.
|
[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
}
}
|
Refer the help documentation.
Regards,
Thavasianand S.
JJ
Juan José
March 1, 2019 02:26 PM UTC
Thanks so much!
TS
Thavasianand Sankaranarayanan
Syncfusion Team
March 4, 2019 04:10 AM UTC
Hi Juan,
We are happy that the problem has been solved.
Please get back to us if you need any further assistance.
Regards,
Thavasianand S.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
JJ Juan José
- Mar 1, 2019 02:24 AM UTC
- Mar 4, 2019 04:10 AM UTC