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

Need to bind SIMPLE dropdown in MVC core grid , having Y and N value

There will be a Grid in my application, i need to create a dropdown column which will have Y and N as values 

No need to fetch these Y and N values from server side 

Please comment how it will be done

Thanks in advance 
Praveen



1 Reply

TS Thavasianand Sankaranarayanan Syncfusion Team February 26, 2019 05:52 AM UTC

Hi Praveen, 

Greetings from Syncfusion. 

We can achieve your requirement using the load event and edit property in Grid. In the below code example we have bind local data for “Verified“ column in Grid. 


<ejs-grid id="Grid" dataSource="ViewBag.dataSource" allowPaging="true" load="load" > 
    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editSettings> 
    <e-grid-columns> 
        <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="100"></e-grid-column> 
        <e-grid-column field="CustomerID" headerText="Customer ID" width="100"></e-grid-column> 
        <e-grid-column field="Freight" width="100" format="C5"></e-grid-column> 
        <e-grid-column field="Verified" headerText="Verified" width="100"></e-grid-column> 
        <e-grid-column field="OrderDate" headerText="Order Date" width="90" format="yMd"></e-grid-column> 
    </e-grid-columns> 
</ejs-grid> 
 
<script> 
    var dropDownData = [{ "Verified": "Y", "SNO": 1 }, { "Verified": "N", "SNO": 2 }]; 
 
    function load(args) { 
 
        this.columns[3].edit = { 
 
            create: function () { 
                elem = document.createElement('input'); 
                return elem; 
            }, 
            read: function () { 
                return dropdownObj.value; 
            }, 
            destroy: function () { 
                dropdownObj.destroy(); 
            }, 
            write: function (args) { 
                dropdownObj = new ej.dropdowns.DropDownList({ 
                    dataSource: dropDownData, 
                    fields: { text: "Verified", value: "Verified" }, 
                    value: args.rowData[args.column.field] 
                }); 
                dropdownObj.appendTo(elem); 
            } 
        } 
    } 
</script> 


Refer the help documentation. 



Please let us know if you need further assistance on this. 
  
Regards, 
Thavasianand S. 


Loader.
Live Chat Icon For mobile
Up arrow icon