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.
Syncfusion Feedback

Binding source data to DropDownList in Template for Grid with EditMode = InlineTemplateForm

Thread ID:

Created:

Updated:

Platform:

Replies:

117404 Oct 14,2014 05:14 PM UTC Oct 15,2014 08:49 AM UTC ASP.NET MVC 1
loading
Tags: Grid
CS
Asked On October 14, 2014 05:14 PM UTC

Using the normal dropdownlist with binding is not an issue.

But I'm trying to create a dropdownlist in the editing template of Grid.

This is the code snippet used:

<script id="TemplateEdit" type="text/template">
        <b>Order Details</b>
        <input id="txtId" name="Id" value="{{: Id}}" disabled="disabled" style="display:none" />

        <table cellspacing="10">
            <tr>
                <td style="text-align: right;">
                    Login Name
                </td>
                <td style="text-align: left">
                    @{
                        var ddlLoginNameBuilder = Html.EJ().DropDownList("ddlLoginName");
                        ddlLoginNameBuilder.TargetID("ddlLoginName");
                        ddlLoginNameBuilder.DropDownListFields(f => f.Text("LoginName"));
                        ddlLoginNameBuilder.Datasource(ViewBag.listOfLogin);
                        ddlLoginNameBuilder.Render();
                    }
                </td>

I've got the error message of which I've no idea about:

Object reference not set to an instance of an object.

and the stack trace:
[NullReferenceException: Object reference not set to an instance of an object.]
   Syncfusion.JavaScript.Control.Render() +64
   Syncfusion.JavaScript.DropDownListPropertiesBuilder.Render() +13
   ASP._Page_Views_Home_Index_cshtml.Execute() in t:\Web\Views\Home\Index.cshtml:87
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +199
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +256
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +52



Alan Sangeeth S [Syncfusion]
Replied On October 15, 2014 08:49 AM UTC

Hi CS,

 

Thanks for using Syncfusion Products.

 

We would like to let you know that we have implemented a feature “EditingTemplate”, which will be included in 2014 Volume 3 release, by which you can render any Syncfusion control like dropdown to the editing form. Please refer the following online sample further reference.

 

Online Sample: http://mvc.syncfusion.com/demos/web/Grid/InlineFormEditing

 

And as for now we have achieved you requirement by rendering Dropdown control in “actionComplete” Grid event. Please refer the following code snippets.

@(Html.EJ().Grid<EJGrid.Models.Order>("Editing")

...

.ClientSideEvents(eve => { eve.ActionComplete("complete"); })

)

 

function complete(args) {

if ((args.requestType == "beginedit" || args.requestType == "add") && args.model.editSettings.editMode == "inlineformtemplate") {

            var data =  @Html.Raw(Json.Encode(ViewBag.dropDownData))

            $("#ShipCountry").ejDropDownList({ width: '116px', dataSource:data });

}

 

For your convenience we have created a sample and the same can be downloaded from below link.

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/EJGrid-505586288.zip

 

Please let us know if you need any further assistance.

Regards,
Alan Sangeeth S


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon 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.Close Icon

;