APYDataGridBundle icon indicating copy to clipboard operation
APYDataGridBundle copied to clipboard

Select filter with null value

Open olivier3400 opened this issue 11 years ago • 8 comments

Hi,

In my development I don't set the filter operators visible. When I use a select filter with the default operator to "eq" and a selectFrom to "source", everything works fine until there is no null values in the list. But if you have some null values, you get a second empty line in the filter values (you can overwrite the second filter by "-empty-" if you want in the twig select block) and the filter doesn't work because the system waits for operator "not contains in" but not "eq". Is it possible to create a new operator that mixes the 2 cases upside to be able to select null values in the select filter ?

Olivier

olivier3400 avatar May 17 '13 12:05 olivier3400

You have the is null operator to select the real null values.

Abhoryo avatar May 21 '13 06:05 Abhoryo

Yes of course, but in a select filter it is not natural to switch between is null or eq operator. And when operator isn't visible you cannot do it. I would be better to add an operator which do the two if possible.

2013/5/21 Petit Yoann [email protected]

You have the is null operator to select the real null values.

— Reply to this email directly or view it on GitHubhttps://github.com/Abhoryo/APYDataGridBundle/issues/413#issuecomment-18192125 .

olivier3400 avatar May 21 '13 07:05 olivier3400

Technically when you work with SGDB as SQL, you write WHEN my_value IS NULL not WHEN my_value = null. Plus, filters can't handle directly null values with others operators.

The first question is what do you put in the value field for your -empty- option ?

Abhoryo avatar May 21 '13 08:05 Abhoryo

I put no value (I tried 'is null' but of course it does work). What it would be splendid is to have an oparator that do an 'eq' when the value is not empty and an 'is null' when empty. It's what i am looking for. Of course you can switch manually to the good operator if you have the operators visible but it is not friendly usage ... and when the operators are not visible !

2013/5/21 Petit Yoann [email protected]

Technically when you work with SGDB as SQL, you write WHEN my_value IS NULL not WHEN my_value = null. Plus, filters can't handle directly null values with others operators.

The first question is what do you put in the value field for your -empty- option ?

— Reply to this email directly or view it on GitHubhttps://github.com/Abhoryo/APYDataGridBundle/issues/413#issuecomment-18195046 .

olivier3400 avatar May 21 '13 17:05 olivier3400

For some operators we can switch the empty value to a null value. But that can bring BC so we have to do this with an option.

I want to add the option nullValue for a column (maybe source too).

By default: nullValue = false, then no null value is considered. If nullValue='', then if an empty value is found, then we switch to the isNull operator is the previous operator is eq. If nullValue='NULL', then if an 'NULL' value is found, then we switch to the isNull operator is the previous operator is eq. If nullValue='vide', then if an 'vide' value is found, then we switch to the isNull operator is the previous operator is eq. ...

Abhoryo avatar May 22 '13 07:05 Abhoryo

It will be perfect :)

When do you think you'll include this feature ? In the next commit or later ?

2013/5/22 Petit Yoann [email protected]

For some operators we can switch the empty value to a null value. But that can bring BC so we have to do this with an option.

I want to add the option nullValue for a column (maybe source too).

By default: nullValue = false, then no null value is considered. If nullValue='', then if an empty value is found, then we switch to the isNull operator is the previous operator is eq. If nullValue='NULL', then if an 'NULL' value is found, then we switch to the isNull operator is the previous operator is eq. If nullValue='vide', then if an 'vide' value is found, then we switch to the isNull operator is the previous operator is eq. ...

— Reply to this email directly or view it on GitHubhttps://github.com/Abhoryo/APYDataGridBundle/issues/413#issuecomment-18262681 .

olivier3400 avatar May 22 '13 08:05 olivier3400

I don't know yet.

Abhoryo avatar May 22 '13 08:05 Abhoryo

Are there any updates on this? My specific case is this: I want to render the isNull and isNotNull operators as checkboxes (like the expanded select filter).if the user selects none of them, then no value will be included.if he checks both of them then naturally all values will be included ( since they're either Null or NotNull). if only one of them is selected then the appropriate operator will be used to filter the results.
I would Implement this myself however I have two problems:

  1. I don't know how the switchOperator Javascript function works.
  2. I don't know how to filter columns based on two operators at the same time.

thedamnedrhino avatar Jan 11 '15 08:01 thedamnedrhino