We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How render ejControls in the Edit Form Template of the MVC Grid?

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.

Article ID: Published Date: Last Revised Date: Platform: Control:
7746 06/05/2017 06/05/2017 ASP.NET MVC Grid
Did you find this information helpful?
Comments
Chris K Mar 14, 2018

Can this be accomplished with a dialog template?

Reply
Seeni Sakthi Kumar Seeni Raj [Syncfusion] Mar 16, 2018

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.

Reply
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.