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

Custom adaptor for auto complete

Thread ID:

Created:

Updated:

Platform:

Replies:

146858 Aug 22,2019 10:03 PM UTC Aug 23,2019 10:06 AM UTC Blazor 1
loading
Tags: AutoComplete
Paul Skelton
Asked On August 22, 2019 10:03 PM UTC

I see that the latest version support custom adaptors but I can't find any documentation and haven't figured out how to make one.  I have a business object that returns the data I need and no web api.  I'd like to write a custom adaptor to interact with my business object and return results.  But how?

Gopi Govindasamy [Syncfusion]
Replied On August 23, 2019 10:06 AM UTC

Hi Paul,  

We have checked your requirement for “custom adaptors with autocomplete component”. We have prepared sample for custom adaptor to load the datasource into autocomplete component. Please find the sample and code snippet for your reference. 

<EjsAutoComplete TValue="string"> 
    <EjsDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></EjsDataManager> 
    <AutoCompleteFieldSettings Value="CustomerID"></AutoCompleteFieldSettings> 
</EjsAutoComplete> 
 
@code{  
 
    public class Orders 
    { 
        public Orders() { } 
        public Orders(int OrderID, string CustomerID) 
        { 
            this.OrderID = OrderID; 
            this.CustomerID = CustomerID; 
        } 
        public int OrderID { get; set; } 
        public string CustomerID { get; set; } 
    } 
    public class CustomAdaptor : DataAdaptor 
    { 
        static readonly HttpClient client = new HttpClient(); 
        public static List<OrdersDetails> order = OrdersDetails.GetAllRecords(); 
        public override object Read(DataManagerRequest dm, string key = null) 
        { 
            IEnumerable<OrdersDetails> DataSource = order; 
            if (dm.Search != null && dm.Search.Count > 0) 
            { 
                DataSource = DataOperations.PerformSearching(DataSource, dm.Search);  //Search 
            } 
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting 
            { 
                DataSource = DataOperations.PerformSorting(DataSource, dm.Sorted); 
            } 
            if (dm.Where != null && dm.Where.Count > 0) //Filtering 
            { 
                DataSource = DataOperations.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator); 
            } 
            int count = DataSource.Cast<OrdersDetails>().Count(); 
            if (dm.Skip != 0) 
            { 
                DataSource = DataOperations.PerformSkip(DataSource, dm.Skip);         //Paging 
            } 
            if (dm.Take != 0) 
            { 
                DataSource = DataOperations.PerformTake(DataSource, dm.Take); 
            } 
            return dm.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource; 
       } 
    } 
} 


We will include this custom adaptor document in our UG, which will be available at the end of August 2019.  

Regards,
Gopi G. 



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