Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Filtering doesn't work if column name has space [Sponsored: Due March 1] #224

Closed
martinbaste opened this issue Nov 6, 2018 · 7 comments
Closed
Assignees
Labels
dash-meta-sponsored Development that has been sponsored by an organization https://plot.ly/products/consulting-and-oem/ dash-type-bug Something isn't working as intended size: 0.5
Milestone

Comments

@martinbaste
Copy link

martinbaste commented Nov 6, 2018

Filtering on columns that contain a space in their name results in the filter string being considered as invalid.

After looking at the docs, it most likely is that the filter parser is being confused when turning the filter string into <column name> <operator> <value>

Temporary fix is, of course, removing spaces from column names.

@Marc-Andre-Rivet
Copy link
Contributor

Thanks for reporting.

@Marc-Andre-Rivet Marc-Andre-Rivet added dash-type-bug Something isn't working as intended Attribute: Functionality labels Nov 6, 2018
@martinbaste
Copy link
Author

Symbols (including periods and parentheses) seem to cause trouble as well.

@yanpanlau
Copy link

Yes I am seeing the same problem too.

@chriddyp
Copy link
Member

chriddyp commented Feb 4, 2019

When this is fixed, let's report back to this community thread: https://community.plot.ly/t/dash-table-filtering-not-working-with-spaces-in-header/18036

@chriddyp chriddyp added the dash-meta-sponsored Development that has been sponsored by an organization https://plot.ly/products/consulting-and-oem/ label Feb 4, 2019
@chriddyp chriddyp changed the title Filtering doesn't work if column name has space Filtering doesn't work if column name has space [Sponsored: Due March 1] Feb 4, 2019
@philspbr
Copy link

This is still broken for me on Dash 3.6.0
I am looping through the columns for conditional formatting like this

styles = [{
    if': {
        'column_id': str(x),
        'filter': '{} < num(0.5)'.format(x)
    },
    'color': 'red',
} for x in df]

If I apply this styline in the layout with style_data_conditional=styles the table is not rendered if a column name contains a space.

@Marc-Andre-Rivet
Copy link
Contributor

Marc-Andre-Rivet commented Jul 10, 2019

Reviewing this in Dash v1.0.1 (dash-table==4.0.1), this seems to be working fine.

The syntax has changed a bit with the v1.0 migration. This syntax should now work:

            style_data_conditional: [{
                if: { column_id: 'my rows', filter_query: '{my rows} is odd' },
                backgroundColor: 'red'
            }, {
                if: { filter_query: '{c*c()c+-&} is even' },
                backgroundColor: 'blue'
            }]

Also reviewing in Dash v0.43 (dash-table==3.7.0), this also seems to be working fine, albeit with the old syntax.

            style_data_conditional: [{
                if: { column_id: 'my rows', filter: '{my rows} is odd' },
                backgroundColor: 'red'
            }, {
                if: { filter: '{c*c()c+-&} is even' },
                backgroundColor: 'blue'
            }]

image

Note: I just realized I wrote this using the JS interface of the table, which does not impact functionality but will need a slight adjustments for Python usage.

@Marc-Andre-Rivet
Copy link
Contributor

@philspbr Closing this as fixed but do not hesitate to open a new issue with a minimum reproducible example if you encounter this problem again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dash-meta-sponsored Development that has been sponsored by an organization https://plot.ly/products/consulting-and-oem/ dash-type-bug Something isn't working as intended size: 0.5
Projects
None yet
Development

No branches or pull requests

5 participants