Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter with null value in cell can't be reset #34

Open
Robbe64 opened this issue May 12, 2017 · 1 comment
Open

Filter with null value in cell can't be reset #34

Robbe64 opened this issue May 12, 2017 · 1 comment

Comments

@Robbe64
Copy link

Robbe64 commented May 12, 2017

Not sure if this is an issue of aurelia-talbe:

I have a filter for a column with some null values.
I'm able to init the filter with null to see all entries but after I typed something in the filter input and removed it again the filter is set to an empty string.
This results in not showing all rows having null in this column.

@daniele-j2ee
Copy link

daniele-j2ee commented Mar 12, 2018

@Robbe64 Yes, I think it's an issue, I faced out the same error.

When you init the filter value to null, au-table doesn't filter the row, so you will see all the entries.
And every time you programmatically reset the filter value to null, you will see all the entries.

But when you bind a filter value to an html input value, things go in a different way, because Aurelia.io framework accepts to change a model value to an empty string '' from null in the case that a user enters a value and then subsequently backs out that value.

This behaviour is explained in the Aurelia.io framework issue #288 and #308, and they suggest to use a NullToEmptyStringValueConverter.

I report here the cause
from issue #288:

The primary issue is the input element's value property only stores strings. The element converts null/undefined to empty string.

and from issue #308:

This behaviour is caused by html elements not supporting null values, the value is altered to empty-string. Aurelia supports this in its binding processing. When changing a model property from "some text" to null, this triggers:

1: Aurelia binding ValueAttributeObserver coerces null newValue to empty-string
2: Value detects element.value not equal newValue, so updates the element with newValue and calls notify
3: Notify calls element value subscribers with coerced empty-string
4: The Binding subscriber compares newValue empty-string with evaluated source expression which is still null ...
5: and so updates source model with newValue empty-string.

Seeing the source, I think the AureliaTableCustomAttribute.prototype.passFilter() function should NOT filter rows when filter value is an empty string.

daniele-j2ee pushed a commit to daniele-j2ee/aurelia-table that referenced this issue Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants