Dash_table_experiments to Dash_table

Hi there!!

I updated my dash version from 0.40.00 and the module Dash_table_experiments stopped working. After looking around I changed it to Dash_table.

I had this code:

dt.DataTable(rows=map_data.to_dict('records'),
                   columns=map_data.columns,
                   row_selectable=True,
                   filterable=True,
                   sortable=True,
                   selected_row_indices=[],
                   id='datatable')

And I changed it for this one:

dt.DataTable(data=map_data.to_dict('records'),
                   columns=map_data.columns,
                   row_selectable='multi',
                   filter_action=True,
                   sort_action=True,
                   selected_rows=[],
                   id='datatable'),

And I get this error. Any idea why?

Invalid argument columns[0] passed into DataTable with ID “datatable”.
Expected object.
Was supplied type string.

Try

columns=[{"name": i, "id": i} for i in df.columns],

Thanks @chriddyp!!

So that if someone with similar problem finds this thread,
what Chris suggested works perfectly but I also had to change these 2 from True to ‘native’:

filter_action='native',
sort_action='native',

The styling of the table just explode, I’ll try to fix that later and the map based on the values of the table isn’t appearing. So …still some issues to figure out.

Older look:

look now:

@chriddyp I almost regret the update of dash version!!:unamused:

Can’t manage to make my callbacks to work with dash_table!

I have 2 filters applying to the data that will show in data table. They both show just fine but the callback isn’t working.

dcc.Checklist( id = 'Tramos', options=[
                                {'label': 'Tramo 1   ', 'value': '1'},
                                {'label': 'Tramo 2   ', 'value': '2'},
                                {'label': 'Tramo 3   ', 'value': '3'}],
                    value=['1','2','3'],
                    labelStyle={'display': 'inline-block'})

and in the callback I have:

@app.callback(
    Output('datatable', 'rows'),
    [dash.dependencies.Input('Tramos', 'values'),
    dash.dependencies.Input('Tipos2', 'value')])

def update_selected_rows(tramos, tipos2):
    map_aux = map_data.copy()
    map_aux = map_aux[map_aux['Tramo'].isin(tramos)]
    map_aux = map_aux[map_aux['Tipo'].isin(tipos2)]
    rows = map_aux.to_dict('records')
    return rows

TypeError: only list-like objects are allowed to be passed to isin(), you passed a [NoneType]

How can I change it to be a list?