We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Grid.filterByColumn() generates an OR query

When I call Grid.filterByColumn('column1, 'equal', value) more than once, I would expect it to replace the previous filter value for column1Instead it adds each filter value to the last resulting in an OR query being sent to the server.

I've tried calling Grid.clearFiltering('column1') but that appears to clear all the filters AND does a post to the server which I don't want, as then when I call filterByColumn() I'm hitting the serve twice for one filter change.

I can't think of a reason why this makes any sense. Is there a way to get subsequent calls to filterByColumn() for the same column to overwrite the previous filter value rather than add it to an OR query?


4 Replies

RO Rob April 18, 2023 04:45 PM UTC

It only seems to happen when setting the filter to a string value and then to null and back again.

So if you call e.g.

filterByColumn('column1', 'equal', 'ID123')

And then:

filterByColumn('column1', 'equal', 'ID456')

It works fine, doesn't create an OR query.

But then if you call:

filterByColumn('column1', 'equal', null)

You end up with an OR query like this:

"OR": [

{

"column1": {

"equals": "ID456"

}

},

{

"column1": {

"equals": null

}

}

]



HK Harini Kannan Syncfusion Team April 26, 2023 11:05 AM UTC

Hi Rob,


Query : Grid.filterByColumn() generates an OR query


After reviewing your query, we noticed that when filtering with filterByColumn('column1', 'equal', null) null value both null and undefined is filtered.

Then filtering with string column filterByColumn('column1', 'equal', string)  empty string , null and undefined these three will be filtered. This is the default behaviour of filterByColumn() method.


filterByColumn('column1', 'equal', null)


  1. Null value


2. Undefined value



Kindly get back to us if you have any concern.


Regards,

Harini




RO Rob April 26, 2023 11:12 AM UTC

This doesn't make a lot of sense.


If I call filterByColumn() several times, each time it should replace the filter (not add to it as it sometimes does).


Instead it sometimes generates an OR query.


How would it ever make sense to filter by e.g.


'123' OR null OR undefined



HK Harini Kannan Syncfusion Team April 27, 2023 11:13 AM UTC

Hi Rob,

 

Query : Grid.filterByColumn() generates an OR query

 

As per your query we want to tell you that the null values are not added to the previous filter. If you are still facing the issue please share your following details.

 

  • Complete grid rendering code.
  • Simple sample to reproduce the issue you are facing.
  • Syncfusion package version

 

Please get back to us if you have any concern.

 

Regards,

Harini


Loader.
Live Chat Icon For mobile
Up arrow icon