Filtering Custom Adapter Component

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,

6 Replies

PM Ponmani Murugaiyan Syncfusion Team February 7, 2022 03:01 PM UTC

Hi Daniel, 

Qyery1: I would like to inject filtering from the dropdown list.
 

If you want to filter the items based on multiple fields, we suggest you to use the ‘Predicate’ in the Filtering event. please check the code below. 

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); 
    } 

Query2: Need to understand how to apply this to the custom adapter component 

We have prepared sample with DropDownList custom adaptor, please find the attached sample below: 


Regards, 
Ponmani M 



DR Daniel Reibelt February 7, 2022 07:34 PM UTC

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>



PM Ponmani Murugaiyan Syncfusion Team February 8, 2022 03:04 PM UTC

Query: Field value search works, but not secondary field "Description". 
 
To enable the filtering with multiple fields, we suggest you to use the predicate options as like previously suggested sample. If you are facing complexities, please share the issue reproducing sample to check and provide you the solution at earliest. 

Regards, 
Ponmani M 




DR Daniel Reibelt February 16, 2022 01:44 PM UTC

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



PM Ponmani Murugaiyan Syncfusion Team February 17, 2022 05:06 PM UTC

Hi Daniel, 

Currently we are checking your reported query, will update further details in 2 business days (February 21, 2022). 

Regards, 
Ponmani M 



PM Ponmani Murugaiyan Syncfusion Team February 21, 2022 12:45 PM UTC

Hi Daniel, 
 
We have considered this issue in our end, we will include the fix in the upcoming patch release which is expected to be rolled out on February 23, 2022. 
 
Regards, 
Ponmani M 


Loader.
Up arrow icon