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 does not support empty strings #569

Closed
Marc-Andre-Rivet opened this issue Sep 5, 2019 · 1 comment · Fixed by #570
Assignees
Milestone

Comments

@Marc-Andre-Rivet
Copy link
Collaborator

@Marc-Andre-Rivet Marc-Andre-Rivet commented Sep 5, 2019

Running the following code will fail with an AST error

import dash

from dash_table import DataTable

app = dash.Dash(__name__)

app.layout = DataTable(
    id='table',
    columns=[{
        'name': x,
        'id': x,
        'selectable': True
    } for x in ['a', 'b', 'c']],
    data=[{
        'a': str(x) if x % 2 == 0 else '',
        'b': x if x % 3 == 1 else '',
        'c': str(x*x) if x % 4 == 2 else ''
    } for x in range(0,100)],
    style_data_conditional=[{
        'if': {
            'column_id': x,
            'filter_query': '{{{}}} eq ""'.format(x)
        },
        'backgroundColor': 'pink'
    } for x in ['a', 'b', 'c']]
)

if __name__ == '__main__':
    app.run_server(debug=True)

This is due to https://github.com/plotly/dash-table/blob/master/src/dash-table/syntax-tree/lexeme/expression.ts#L7 requiring at least one character inside the string. Removing this requirement will make the above code work as expected.

@alexcjohnson

This comment has been minimized.

Copy link
Contributor

@alexcjohnson alexcjohnson commented Sep 5, 2019

Related: #544

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.