Fuzzy search with ODataV4Adaptor

Hello, is it possible to apply custom filtering on a dropdownlist populated via ODataV4Adaptor ?

I would like to fuzzy search.

Thanks

JF



1 Reply 1 reply marked as answer

SP Sureshkumar P Syncfusion Team October 10, 2022 11:30 AM UTC

Hi Jean,

We suggest you use the below code example to achieve the custom filtering on ODataV4Adaptor.

Find the code example here:

@using Syncfusion.Blazor.Data

@using Syncfusion.Blazor.DropDowns

 

<SfDropDownList @ref=ddlObj TValue="string" AllowFiltering="true" TItem="OrderDetails" Placeholder="Select a customer" Query="@Query">

    <SfDataManager Url="https://services.odata.org/V4/Northwind/Northwind.svc/Orders" Adaptor="Syncfusion.Blazor.Adaptors.ODataV4Adaptor" CrossDomain=true></SfDataManager>

    <DropDownListFieldSettings Text="CustomerID" Value="OrderID"></DropDownListFieldSettings>

    <DropDownListEvents TValue="string" TItem="OrderDetails" Filtering="CustomFiltering"></DropDownListEvents>

</SfDropDownList>

 

@code {

    SfDropDownList<string, OrderDetails> ddlObj { get; set; }

 

    async Task CustomFiltering(FilteringEventArgs args)

    {

        args.PreventDefaultAction = true;

        var query = new Query().Where(new WhereFilter() { Field = "CustomerID", Operator = "contains", value = args.Text, IgnoreCase = true });

 

        query = !string.IsNullOrEmpty(args.Text) ? query : new Query();

 

        await ddlObj.FilterAsync(this.ddlObj.DataSource, query);

 

    }

    public Query Query = new Query().Select(new List<string> { "CustomerID", "OrderID" }).Take(6).RequiresCount();

 

    public class OrderDetails

    {

        public int? OrderID { get; set; }

        public string CustomerID { get; set; }

        public int? EmployeeID { get; set; }

        public double? Freight { get; set; }

        public string ShipCity { get; set; }

        public bool Verified { get; set; }

        public DateTime? OrderDate { get; set; }

        public string ShipName { get; set; }

        public string ShipCountry { get; set; }

        public DateTime? ShippedDate { get; set; }

        public string ShipAddress { get; set; }

    }

}

Find the sample in the attachment:

Note: If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.

Regards,

Sureshkumar P


Attachment: DDLServer_235801ff.zip

Marked as answer
Loader.
Up arrow icon