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. Image for the cookie policy date
close icon

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

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



1 Reply

AS Alan Sangeeth S Syncfusion Team 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


Loader.
Live Chat Icon For mobile
Up arrow icon