Client side filtering with UrlAdaptor datasource.

Hello,

I have a Combobox with AllowFiltering = true and load the datasource with UrlAdaptor.

  <SfDropDownList TValue="string" TItem="OptionDto<int>" Placeholder="Szállító" AllowFiltering="true" FloatLabelType="FloatLabelType.Always" Query="cbSzallitokQuery">

                                        <SfDataManager Url="api/szallito/options" CrossDomain="true" Adaptor="Adaptors.UrlAdaptor"></SfDataManager>

                                        <DropDownListFieldSettings Text="Text" Value="Id" />

                                    </SfDropDownList>

                                    <SfButton CssClass="btn-refresh" IconCss="e-icons e-refresh" OnClick="@(() => { cbSzallitokQuery = new Query(); })"></SfButton>

When I use the filter in runtime and type anything, every keypress will be a new request for the api and download the filtered result from database.

I think this is not neccessary, because when I first time dropdown the combo all records will be loaded.

For this reason, client-side filtering would be sufficient I think.

Can you help me please how can I set client-side filtering with the above Combobox?

Thank you!

BR, László


3 Replies

PM Ponmani Murugaiyan Syncfusion Team March 27, 2022 02:40 PM UTC

Hi SZL, 

We have prepared sample for your requirement with custom filtering, please find the sample below for reference. 


    public async Task OnFilterUnidad(FilteringEventArgs args) 
    { 
        args.PreventDefaultAction = true; 
        var pre = new WhereFilter(); 
        var predicate = new List<WhereFilter>(); 
        predicate.Add(new WhereFilter() { Condition = "or", Field = "CustomerID", Operator = "startswith", value = args.Text, IgnoreCase = true }); 
        predicate.Add(new WhereFilter() { Condition = "or", Field = "OrderID", Operator = "contains", value = args.Text, IgnoreCase = true }); 
        pre = WhereFilter.Or(predicate); 
        var query = new Query().Where(pre).Take(10); 
        await this.autoObjUnidad.Filter(null, query); 
    } 

Regards, 
Ponmani M 



SZ SZL replied to Ponmani Murugaiyan March 28, 2022 10:36 AM UTC

Hi,


Thank you, this example is very good for custom filtering, but for my question I found an another solution with Offline property:


<SfDataManager Url="api/szallito/options" CrossDomain="true" Adaptor="Adaptors.UrlAdaptor" Offline="true"></SfDataManager>


So my problem is solved. Thanks!

BR, SZL



PO Prince Oliver Syncfusion Team March 30, 2022 07:32 AM UTC

Hi SZL,


Most welcome, we are glad to know that your requirement is met.

Regards,

Prince

Loader.
Up arrow icon