Grid - DropDown

Hi,

I've been trying to figure this out from the documentation, but have been unable to:

Is it possible to add your own data to a DropDownList that is being used within a Grid.

eg. Can I add custom data to the dropdown below?
<ej:Grid ID="FlatGrid" runat="server" AllowPaging="True">
           <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True" EditMode="Normal"></EditSettings>
           <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings>
           <Columns>
                <ej:Column Field="ShipCountry" EditType="Dropdown"/>

1 Reply

AS Alan Sangeeth S Syncfusion Team April 4, 2017 11:59 AM UTC

Hi Danie, 

Thanks for using Syncfusion products. 
You can set your own data to a DropdownList EditType Column in code behind using “DataSource” property of Grid column. Please refer the following code example. 

protected void Page_Load(object sender, EventArgs e) 
        { 
 
var colData  = new NORTHWNDEntities().Orders.Select(ds =>ds.ShipCountry).Distinct().ToList(); 
            List<object> dataPair = new List<object>(); 
           for (var i = 0; i < colData.Count; i++) 
           { 
               dataPair.Add(new {text = colData[i], value = colData[i]}); 
           } 
               this.EmployeesGrid.Columns.ElementAt(index).DataSource = dataPair; 
        } 

Note: We need to bind datasource for dropdown column as text and value pair. 

We have created a sample based on your requirement that can be downloadable from below link 


Regards,
Alan Sangeeth S 


Loader.
Up arrow icon