Obtaining information from datatable selected_rows

Hi team,

I’m trying to update 2 dropdowns using value from a datatable (single selection only), upon a row been selected. I’m running into error after selecting the row. I’m wondering if I am not using the “selected_rows” property right.

Many thank for any help.

    [Output('dropdown1', 'value'),
    [Input('datatable', 'data'),
     Input('datatable', 'selected_rows')

def update_dropdown(data,selected_rows):

    return dropdown1, dropdown2

Hi @Felton
What’s the error message that you get?

Is ‘columm1’ the exact name of the column?

Right above the dropdown1=… code line, try print(selected_rows) and see what you get.

Hi Adam thanks for the reply.

The error msg is “TypeError: list indices must be integers or slices, not NoneType”. Which suggest the value of selected_rows is empty. My table looks like the below.

Column name is correct as when i substitute selected_rows with a number, eg 1, the code works.


I’m not sure why that is happening. If you select a row, and you print(selected_rows), you get an empty list?

I solved it. Turned out the selected_row was returning a list where I thought it was an integer. So instead of

I had to change it to

Thanks for your replies Adam.

It’s a good idea to always print(x) or print(type(x)) to see what the input looks like.
I’m glad you solved it.