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

IEnumerable<string> as Datasource?

Thread ID:

Created:

Updated:

Platform:

Replies:

151122 Jan 31,2020 11:26 AM UTC Feb 10,2020 10:10 AM UTC Blazor 3
loading
Tags: AutoComplete
axl
Asked On January 31, 2020 11:26 AM UTC

Hi,

the examples for the Autocomplete use always objects with propertties as data source. How can one attach a straightforward IEnumerable<string> or List<string>? The following code does not succeed and the popup states 'The Request Failed'.


<EjsAutoComplete TValue="string" Placeholder="e.g. Australia" DataSource="@LocalData">
</EjsAutoComplete>
@code {

List<string> LocalData = new List<string> { "Australia","Bermuda","Canada","Cameroon","Denmark","France"};

}
The documentation for Autocomplete has no information about this. I guess the AutoCompleteFieldSettings could be helpfull. But how to configure if no object with properties is bound but a plain string?

Sincerly, Axel.


Sureshkumar P [Syncfusion]
Replied On February 3, 2020 09:55 AM UTC

Hi Axel, 
 
Greetings from Syncfusion support. 
 
We have checked the reported requirement. We don't have string dataSource support for the autocomplete component. So as of now, you can convert the string array to list type as mentioned below code snippet 
 
 
List<string> CountryList = new List<string> { "Australia", "Bermuda", "Canada", "Cameroon", "Denmark", "France" }; 
 
protected override void OnInitialized() 
{ 
    LocalData = CountryList.Select(x => new CountryData() 
    { 
            CountryName = x 
        }).ToList(); 
} 
 
We have already considered it as feature, and it will be included in our upcoming volume-1 release. Which is expected to be rolled out on end of March 2020. We appreciate your patience until then. You can track the status of the feature in the below feedback link from below.   
 
 
Regards, 
Sureshkumar P 


axl
Replied On February 8, 2020 11:29 AM UTC

Okay, I get it. Thank you.
No problem at the moment, but I just want to make sure I didn't miss anything and use an additional proxy class for no reason. Especially since the documentation explicitly talks about string arrays (https://ej2.syncfusion.com/blazor/documentation/autocomplete/getting-started/#binding-data-source: ...Here, an array of string values is passed to the AutoComplete component ...). Even if the actual code example does not match the text at this point - a model class is bound and not an array. The documentation surely needs some more attention to be more precise.

Sincerly, Axel.

Sureshkumar P [Syncfusion]
Replied On February 10, 2020 10:10 AM UTC

Hi Axel, 
 
Thanks for the valuable suggestion. We will modify the content and refresh the documentation soon. We will intimate you once the document will be published. 
 
Regards, 
Sureshkumar P 


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