dash-table icon indicating copy to clipboard operation
dash-table copied to clipboard

row_selectable and filter_action causes error Cannot ready property '0' of undefined

Open jchang10 opened this issue 5 years ago • 1 comments

Individually, works fine. With both row_selectable and filter_action defined, a JS error is caused, "Cannot ready property '0' of undefined. It's an obscure error, so in a page with several components, it can be hard to pinpoint the cause.

Versions: dash 1.17.0
dash-bootstrap-components 0.10.7
dash-core-components 1.13.0
dash-html-components 1.1.1
dash-renderer 1.8.3
dash-table 4.11.0

Very straight-forward simple example below.

import logging
logger = logging.getLogger(__name__)

from dash_html_components import Div, Span
import dash_table
import dash

app = dash.Dash(__name__)

app.layout = \
    Div([
        dash_table.DataTable(id='samples-table',
            row_selectable='multi',
            style_table=dict(height='300px',overflowY='auto'),
            style_cell={'textAlign': 'left'},
            sort_action='native',
            filter_action='native',
        ),
        Div(id='last-div'),
    ])

import pandas as pd
from dash.dependencies import Input, Output, State

@app.callback(
    Output('samples-table','data'),
    Output('samples-table','columns'),
    Input('last-div','children'),
)
def samples_table(*args):
    df = pd.DataFrame([[1,2,3],[4,5,6]])
    data = df.to_dict('records')
    columns = [{'name':str(x),'id':str(x)} for x in (1,2,3)]
    return data, columns


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


jchang10 avatar Nov 13 '20 17:11 jchang10

#826 Seems related.

It looks like if I seed the data and columns in the layout first, the error disappears. If data and column are not seeded initially, then the error appears.

jchang10 avatar Nov 15 '20 02:11 jchang10