How can we create data columns in Dash Table dynamically using callback with a function providing the dataframe

后端 未结 2 340
故里飘歌
故里飘歌 2021-01-17 08:23

I am trying to create dash table on Web using Inputs. However the issue is that the data is created from database from the callback and a priori, I do not know the names of

2条回答
  •  囚心锁ツ
    2021-01-17 09:20

    If I've understood you correctly, then you can simply create another callback which outputs the updated value for the columns prop. You could also use a multi-output callback to update both at the same time.

    @app.callback(Output('table', 'columns'),
        [Input('submit', 'n_clicks')],
        [State('ID', 'value'),  State('pattern_desc', 'value'), 
         State('file_path', 'value')])
    def update_table(n_clicks, ID, pattern_desc, file_path):
        mydata = someFunc(ID, pattern_desc, file_path)
        # here you would use the dataframe columns to create the new column values
        return new_column_values
    

提交回复
热议问题