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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

142889 Feb 25,2019 09:44 AM UTC Feb 26,2019 05:52 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: DataGrid
Praveen
Asked On February 25, 2019 09:44 AM UTC

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



Thavasianand Sankaranarayanan [Syncfusion]
Replied On 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. 


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.

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

Live Chat Icon For mobile
Live Chat Icon