Issue with excel style filtering on Childgrid

I have a childgrid on one of my projects when I try to do excel type filtering my server Odata API gives an error. The datamanager generates the url as - 
https://localhost:44353/odata/User/?$apply=groupby((UserLastName))&$count=true&$top=1000&$filter=MainId%20eq%209734

I am trying to filter on UserLastName. MainID is the filtering based on the parent key.

The server side api is done using
ASP.NET core 3.1
Microsoft.AspNetCore.Odata v7.3.0
Microsoft EntityFrameworkCore.Design v5.0.1
Microsoft EntityFrameworkCore.Tools v5.0.1
Microsoft EntityFrameworkCore.SqlServer v5.0.1

The error I get is - 
The query specified in the URI is not valid. $apply/groupby grouping expression 'MainId' must evaluate to a property access value."

The URL should be like -
https://localhost:44353/odata/User/?$apply=filter(MainId%20eq%209734)/groupby((UserLastName))&$count=true&$top=1000

How can I make datamanager pass the query as above instead of the default that is generated.

Thanks,

Ameet



3 Replies 1 reply marked as answer

RS Rajapandiyan Settu Syncfusion Team February 10, 2021 11:42 AM UTC

Hi Ameet, 

Thanks for contacting Syncfusion support. 

Query: How can I make datamanager pass the query as above instead of the default that is generated. 
  
By default, the EJ2 Data-Manager generate the request query in standard format for all the grid actions based on the Adaptors. In your requirement, you want to customize the request query when doing action in the child-Gird. 
 
You can achieve your requirement by using custom adaptor functionality. This is explained in the below documentation. 
 
 
By using the custom adaptor, we can extend the built-in adaptor. In the ProcessQuery method, you can modify the request query as per your need. This is demonstrated in the below code snippet, 
  
 
[app.component.ts] 
 
class SerialNoAdaptor extends ODataV4Adaptor { 
  processQuery() { 
    // Executing base class processQuery function 
    var original = super.processQuery.apply(this, arguments); 
    console.log(original); 
    // Here you can customize the request queries as per your need and send it 
    return original; 
  } 
} 
export class AppComponent { 
  public parentData: Object[]; 
  public childGrid: any; 
 
  ngOnInit(): void { 
    this.parentData = employeeData; 
    this.childGrid = { 
      dataSource: new DataManager({ 
        adaptor: new SerialNoAdaptor() 
      }), 
      queryString: "EmployeeID", 
      allowFiltering: true, 
      filterSettings: { type: "Excel" }, 
      ----- 
    }; 
  } 
} 
 
 

Please get back to us if you need further assistance with this.

Regards,
Rajapandiyan S 


Marked as answer

AM Ameet February 19, 2021 12:51 AM UTC

This worked perfectly.

Thanks,

Ameet


RS Rajapandiyan Settu Syncfusion Team February 19, 2021 06:15 AM UTC

Hi Ameet, 

We are glad that the provided solution resolved your requirement. 
 
Please get back to us if you need further assistance with this.

Regards,
Rajapandiyan S 


Loader.
Up arrow icon