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

Can the datasource just be a List<string>?

Thread ID:

Created:

Updated:

Platform:

Replies:

148169 Oct 8,2019 09:44 PM UTC Oct 22,2019 01:38 PM UTC Blazor 4
loading
Tags: Grid
Michael Lambert
Asked On October 8, 2019 09:44 PM UTC

Can the Datasource be bound to a List<string> or does it have to be bound to a 'Dictionary' type class?  I get no items in the dropdown.

<EjsGrid DataSource="@EventList" Height="400" Toolbar="@gridToolbar">
......
        <GridColumn  HeaderText="Type" Width="80" EditType="EditType.DropDownEdit" DataSource="@eventTypes"></GridColumn>
        <GridColumn Field=@nameof(Events.Note) MaxWidth="200" HeaderText="Note" Width="120"></GridColumn>
        <GridColumn Field=@nameof(Events.EventId) HeaderText="ID" Width="120" Visible="false" IsPrimaryKey="true" IsIdentity="true"></GridColumn>
    </GridColumns>
</EjsGrid>


 eventTypes = config.GetSection("EventTypes").Get<List<string>>();

In my AppSettings:
 "EventTypes": [
    "Community",
    "Qualified",
    "Other"
  ]


Vignesh Natarajan [Syncfusion]
Replied On October 9, 2019 11:27 AM UTC

Hi Michael,  

Greetings from Syncfusion support.  

Query: “Can the Datasource be bound to a List<string> or does it have to be bound to a 'Dictionary' type class?  I get no items in the dropdown. 

Yes, we need to bound the dataSource in form of Dictionary type (i.e.) Key and value pair for DropDownList control. We understand that you are facing issue while trying to display data in DropDownList inside the Grid column while editing. From your code example, we found that you have tried to bind the dataSource to Grid column instead of DropDownList. Hence the reported issue (Got no items in dropdown) occur. To resolve the reported issue, we suggest you to define the dataSource to DropDownList instead of grid columns using Edit params property of grid columns.  

Refer the below code example. 

<EjsGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" Height="315"> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn HeaderText="Customer Name" EditType="EditType.DropDownEdit" Edit="@DropParams" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" EditType="EditType.DatePickerEdit" Format="yMd" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"></GridColumn> 
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
    </GridColumns> 
</EjsGrid> 
 
@code{ 
    public static List<Order> Orders { get; set; } 
public static List<Countries> DDLData = new List<Countries> 
{ 
        new Countries() { Name = "Community", Code = "AU" }, 
        new Countries() { Name = "Qualified", Code = "BM" }, 
        new Countries() { Name = "Other", Code = "CA" },        
    }; 
    public object DropParams = new 
    { 
    @@params = new DropDownListModel<string> { DataSource = DDLData, Query = "new ej.data.Query()",Fields= new FieldSettingsModel() { Text = "Name" ,Value="Name" }  } 
    }; 


Refer the below screenshot for the output 

 

For your convenience we have prepared a sample which can be downloaded from below  
  

Note: In you code example, you have not defined Field property to DropDownList column, hence its value will not be saved or displayed in Grid.   

Refer our UG documentation for your reference 



Please get back to us if you have further queries.  

Regards, 
Vignesh Natarajan. 


Michael Lambert
Replied On October 9, 2019 04:07 PM UTC

I find it rather astonishing that you cannot bind your DropDownList to a simple string[].  That should be basic functionality!!

Vignesh Natarajan [Syncfusion]
Replied On October 10, 2019 04:36 AM UTC

Hi Michael, 

Query: “I find it rather astonishing that you cannot bind your DropDownList to a simple string[]. 
 
We have validated the defect you have initiated with us. Thank you for taking the time to report this issue “Not able to bind the dataSource as string[] / list<string> for dropdownlist column” and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including the defect fix in our next Nuget release which is expected to be roll out on or before 23rd October 2019.  
 
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link. 
 
 
Till then we appreciate your patience. 

Regards, 
Vignesh Natarajan. 


Renjith Singh Rajendran [Syncfusion]
Replied On October 22, 2019 01:38 PM UTC

Hi Michael, 

We are glad to inform you that our latest Nuget package (17.3.0.19) has been successfully rolled out. In this release, we have included the fix for the issue “Not able to bind the dataSource as string[] / list<string> for dropdownlist column in Grid”. Please find the latest Nuget package from the link below, 

 
 
Also ensure to refer the latest version script and css in your application.  
 
     
    <link rel='nofollow' href="https://cdn.syncfusion.com/ej2/17.3.19/fabric.css" rel="stylesheet" /> 
 
 
Please get back to us if you have further queries. 

Regards, 
Renjith Singh Rajendran. 
 


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