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ó
|
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);
} |
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
Hi SZL,
Most welcome, we are glad to know that your requirement is met.
Regards,