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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dropdown List with dynamic datasource in Inline Form Template

Thread ID:





131735 Jul 25,2017 02:23 PM UTC Jul 26,2017 01:54 PM UTC ASP.NET MVC 1
Tags: Grid
Asked On July 25, 2017 02:23 PM UTC


how can I build a template for inline form editing with a dropdown list control that has a list of values taken from an array?

In other words:


    var cLocs = @Html.Raw(Json.Encode(@ViewBag.ContractLocations));
    var contractLocations = [];
    for (var i = 0; i < cLocs.length; i++) {
        contractLocations.push({ id: cLocs[i].LocationId, desc: cLocs[i].ShortDes });


                <select id="LocationId" name="LocationId">
                    {{for contractLocations}}

the highlighted part doesn't work...

Thank you.


Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On July 26, 2017 01:54 PM UTC

Hi Claudio,  
Thanks for contacting Syncfusion Support.  
We can bind dataSource to the DropDown in the ActionComplete event of the Grid as shown in the following code example.  
        .Columns(col => 
            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width(90).Add(); 
            col.Field("CustomerID").HeaderText("Customer ID"). Add(); 
           col.Field("EmployeeID").HeaderText("Employee ID").Width(85).Add(); 
             .ClientSideEvents(events => 
<script id="template" type="text/template"> 
    <b>Order Details</b> 
    <table cellspacing="10"> 
               . .  
                   . .  
            <td style="text-align: right;"> 
                Employee ID 
            <td style="text-align: left"> 
                <input type="text" id="EmployeeID" name="EmployeeID" value="{{:EmployeeID}}" /> 
    var cLocs = @Html.Raw(Json.Encode(@ViewBag.data)); 
    function complete(args) { 
        if (args.requestType == "beginedit" || args.requestType == "add") { 
            $("#Freight").ejNumericTextbox({ value: parseFloat($("#Freight").val()), width: "116px", decimalPlaces: 2 }); 
            $("#EmployeeID").ejDropDownList({ width: '116px', dataSource: cLocs, fields: { value: "EmployeeID", text: "FirstName" } }); 
            if (args.requestType == "beginedit") { 
                $("#OrderID").attr("disabled", "disabled"); 
                $("#EmployeeID").ejDropDownList("setSelectedValue", args.row.children().eq(3).text()); 
            $(".e-field").css({ 'width': '116px', 'text-align': 'left' }); 
Here dataSource has been bind to the dropdown without any conversion. Since, we have used the text/value pair DropDownList Fields, we didn’t need to convert them. Please make a note that the eq(3) in the ActionComplete event denotes the Column index of the EmployeeID.  
Seeni Sakthi Kumar S. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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