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:
Image_2393_1728560759316

Image_1554_1728560772931

I created a Query:

new Query().expand('robot($select=name)').where(new Predicate('runtimeId', 'equal', route.params.id.toString()));


This way, the main query worked very well:
Image_3685_1728560854402

However, the problem arises when I try to apply a column filter:
Image_9808_1728560873879

Image_5970_1728560893937
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:
Image_1570_1728561018478

Image_8089_1728561043804

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:
Image_6251_1728561190384

Frontend:

"@syncfusion/ej2-base": "26.1.37",
    "@syncfusion/ej2-buttons": "26.1.40",
    "@syncfusion/ej2-calendars": "26.1.40",
    "@syncfusion/ej2-charts": "26.1.40",
    "@syncfusion/ej2-compression": "26.1.35",
    "@syncfusion/ej2-data": "26.1.40",
    "@syncfusion/ej2-dropdowns": "26.1.40",
    "@syncfusion/ej2-excel-export": "26.1.35",
    "@syncfusion/ej2-file-utils": "26.1.35",
    "@syncfusion/ej2-grids": "26.1.40",
    "@syncfusion/ej2-icons": "26.1.35",
    "@syncfusion/ej2-inputs": "26.1.40",
    "@syncfusion/ej2-lists": "26.1.35",
    "@syncfusion/ej2-navigations": "26.1.40",
    "@syncfusion/ej2-notifications": "26.1.35",
    "@syncfusion/ej2-pdf-export": "26.1.35",
    "@syncfusion/ej2-splitbuttons": "26.1.35",
    "@syncfusion/ej2-svg-base": "26.1.39",
    "@syncfusion/ej2-treegrid": "26.1.40",
    "@syncfusion/ej2-vue-base": "26.1.35",
    "@syncfusion/ej2-vue-buttons": "26.1.40",
    "@syncfusion/ej2-vue-calendars": "26.1.40",
    "@syncfusion/ej2-vue-charts": "26.1.40",
    "@syncfusion/ej2-vue-documenteditor": "26.1.40",
    "@syncfusion/ej2-vue-dropdowns": "26.1.40",
    "@syncfusion/ej2-vue-grids": "26.1.40",
    "@syncfusion/ej2-vue-inputs": "26.1.40",
    "@syncfusion/ej2-vue-layouts": "26.1.38",
    "@syncfusion/ej2-vue-lists": "26.1.35",
    "@syncfusion/ej2-vue-maps": "26.1.35",
    "@syncfusion/ej2-vue-navigations": "26.1.40",
    "@syncfusion/ej2-vue-pdfviewer": "26.1.40",
    "@syncfusion/ej2-vue-popups": "^26.1.38",
    "@syncfusion/ej2-vue-richtexteditor": "26.1.40",
    "@syncfusion/ej2-vue-schedule": "26.1.40",
    "@syncfusion/ej2-vue-splitbuttons": "26.1.35",
    "@syncfusion/ej2-vue-treegrid": "26.1.40",

1 Reply

VK Vasanthakumar K Syncfusion Team October 16, 2024 05:25 PM UTC

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


Loader.
Up arrow icon