Wrong filter with groupBy with OData
Hi guys,
Recently, I started working with the ODataV4Adaptor in the DataGrid and began encountering some issues with column filtering, where the request consistently results in an error. I'll explain how I set it up:
I built an ODataV4Adaptor:
I created a Query:
This way, the main query worked very well:
However, the problem arises when I try to apply a column filter:
I did some research on the topic in the OData GitHub repository and came across this comment:
https://github.com/OData/WebApi/issues/2268#issuecomment-689013510
So, I decided to manipulate the URL on my own to test this theory, and surprisingly, it worked:
Am I doing something wrong here? Is there a practical way to fix this, or could it be a configuration issue in my project?
My project uses:
Backend:
Frontend:
Hi Mario Pries Junior | Martinelli Labs,
Greetings from Syncfusion support.
Query: Recently, I started working with the ODataV4Adaptor in the DataGrid and began encountering some issues with column filtering, where the request consistently results in an error. the problem arises when I try to apply a column filter.
Based on the details you provided, it seems that you are using the filterSettings.type as Checkbox or Excel. By default, when using the Excel/Checkbox filter type with remote data, the grid sends a select query when opening the filter dialog. This query is formatted using groupby, which causes the issue you're experiencing.
To resolve this, you can customize the query in the actionBegin event. When the requestType is filterchoicecount or filterSearchBegin, you can remove the select distinct query to prevent the error.
We've prepared a sample for your reference. In this sample, we assigned an empty array to the distinct values in the actionBegin event for both filterchoicecount and filterSearchBegin. This resolves the issue by eliminating the problematic query format. Please refer the below code example and sample for more details.
[code example]
|
<ejs-grid :dataSource='data' :allowPaging='true' :pageSettings='pageOptions' :allowFiltering='true' :filterSettings='filterSettings' :actionBegin="actionBegin"> . . . . . </ejs-grid>
data() { return { data: new DataManager({ url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Orders', adaptor: new ODataV4Adaptor() }), filterSettings: { type: 'Excel' }, pageOptions: { pageSize: 10, pageCount: 4 }, orderService: new OrderService() }; }, methods:{ . . . . actionBegin(args: any) { if (args.requestType=== 'filterchoicerequest' ||args.requestType=== 'filterSearchBegin') { args.query.distincts= []; // if we comment this line, the customer mentioned case occurs. } } }, |
Sample: https://stackblitz.com/edit/gx9dxk?file=src%2FApp.vue
Regards,
Vasanthakumar K
- 1 Reply
- 2 Participants
-
MP Mario Pries Junior | Martinelli Labs
- Oct 10, 2024 11:54 AM UTC
- Oct 16, 2024 05:25 PM UTC