2X faster development
The ultimate ASP.NET MVC UI toolkit to boost your development speed.
Grid supports several Editors of Syncfusion controls (DatePicker, DateTimePicker and DropDownList) to be rendered in the Editform using the jsrender concept. But MVC controls of the Syncfusion cannot be placed in the edit form using the jsrender concept. However, we have placed the MVC controls within the editform using the partial view concept of the MVC.
Razor
Template rendering in edit form is supported with the InlineFormTemplate and ExternalFormTemplate. To enable these modes, you must mention the EditMode as InlineFormTemplate or ExternalFormTemplate along with the template ID as shown in the following code example.
Editing Template – EditPage.cshtml
In the EditPage.cshtml (a partial view), place the Syncfusion MVC controls as a template to the Edit Form.
Please make a note that the Partial View page is having the ScriptManager to render the Syncfusion Controls. Since we have rendered the controls in the non-unobtrusive mode, we have mentioned this.
We have already discussed about rendering Syncfusion Controls in the Partial Views in following Help Document.
https://help.syncfusion.com/aspnetmvc/grid/how-to#work-with-partial-views
While editing the record we need to pass the primaryKey value of that corresponding record as a query string in the ActionComplete event of grid and call EditPartial method in the Home controller with these details through Ajax call within the same ActionComplete event for rendering the Syncfusion MVC controls in the Edit Form of the Grid after the Ajax success call.
Controller EditPartial Method will handle the Ajax handler of the MVC control rendering and it will receive the ID of the respective editing record using the QueryString. Based on the PrimaryKey value, records were pulled from the server and later assigned to the MVC controls using the MVC model concept.
The following screenshot shows the Grid with Edit form rendered from the partial view and Syncfusion MVC Controls.
Figure: Grid with the inline form template holding MVC controls. |
2X faster development
The ultimate ASP.NET MVC UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.
Can this be accomplished with a dialog template?
Hi Chris,
We can bind editfom from Partial View to the Dialog Template as follows.
<script>
function actionBegin(args) {
if (args.requestType == "save")
this.element.ejWaitingPopup("show");
}
function actionComplete(args) {
var type = args.requestType;
if (type == "beginedit" || type == "add") {
if (!ej.isNullOrUndefined(args.rowIndex))
var OrderID = this.model.currentViewData[args.rowIndex]["OrderID"];
this.element.ejWaitingPopup("show");
$.ajax
({
url: type == "add" ? "/Home/EditPartial" : "/Home/EditPartial?OrderID=" + OrderID,
type: 'GET',
success: ej.proxy(function (data) {
var div = ej.buildTag("div");
$("#" + this._id + "EditForm").prepend($(div).html(data))
if (type != "add") $("#OrderID").addClass("e-disable").attr("disabled", "disabled");
this.element.ejWaitingPopup("hide");
},this)
});
}
if (args.requestType == "save")
this.element.ejWaitingPopup("hide");
}
</script>
Instead of replacing the entire form, we need to prepend the div to them as shown above.
Regards,
Seeni Sakthi Kumar S.