I have a custom Data Adapter as a Compentent.
The example is similar to https://blazor.syncfusion.com/documentation/datagrid/custom-binding#custom-adaptor-as-component
I am also using this adapter inside a dropdown. TItem is a complex object which i want to filter on multiple fields. I would like to inject filtering from the dropdown list.
I have added the Dropdown Event for filtering, but need to understand how to apply this to the custom adapter component
//private async Task OnFilter(FilteringEventArgs args)
{
args.PreventDefaultAction = true;
var query = new Query().Where(
new WhereFilter() { Field = "Description", Operator = "contains", value = args.Text, IgnoreCase = true }
.Or("ID", "equal", args.Text));
query = !string.IsNullOrEmpty(args.Text) ? query : new Query();
// WHAT NEXT - HOW DO I APPLY THIS QUERY TO CUSTOM ADAPTER
}
class MyComplex {
public int ID {get;set;}
public string Description {get;set;}
....
}
PS. Im sure i'll need throttling on this action too,
|
public async Task OnFilter(FilteringEventArgs args)
{
args.PreventDefaultAction = true;
var pre = new WhereFilter();
var predicate = new List<WhereFilter>();
predicate.Add(new WhereFilter() { Condition = "or", Field = "CustomerID", value = args.Text, Operator = "startswith", IgnoreAccent = true, IgnoreCase = true });
predicate.Add(new WhereFilter() { Condition = "or", Field = "OrderID", value = args.Text, Operator = "startswith", IgnoreAccent = true, IgnoreCase = true });
pre = WhereFilter.Or(predicate);
var query = new Query().Where(pre);
await this.autoObj.Filter(this.autoObj.DataSource, query);
} |
Thanks for the feedback, it seems to work but not as expected. Field value search works, but not secondary field "Description"
In the line:
await this.autoObj.Filter(this.autoObj.DataSource, query);
the Datasource parameter is always null, i suspect this is because my adapter is declared as per:
<SfDataManagerAdaptor="Adaptors.CustomAdaptor"><CustomAdaptorComponent></CustomAdaptorComponent></SfDataManager>
The attached sample clarifies my problem.
Using the 18.xxxx version as supplied in your sample, it functions correctly.
Update to the 19.4.0.47-52 it does not with the following issues:
The correct behaviour should search on ID, Description and Customer.Name
Attachment: Blazor_DropDowns1288347005_9877b5e3.zip