I’m currently using a checklist that updates with the columns of a table whenever a new table is created.
convert = lambda text: int(text) if text.isdigit() else text
alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ]
sortlist = sorted(selected, key = alphanum_key)
inters_df = {k: inters_df[k] for k in sortlist}
This code simply just takes the columns of the table and sorts them into alphabetical order. The column names of the sorted dataframe (sortlist
) is then returned to the options
parameter of the checklist component. So on the initial creation of a table, the value
parameter could look like this:
['A1', 'A2', 'A4']
However, a callback was implemented to recreate the table in the exact same format with any new datasets that the user uploads. So the column names would probably change. I set the checklist options
through the exact same process as above, but when the user selects from this new checklist, it would add the selected options on top of the ones selected before the new table was created.
['A1', 'A2', 'A4', 'B1', 'B2']
Which is weird because the checklist itself has been updated with the correct options, without the options of the previous table. The above was printed when using a print statement directly on the State of the value
parameter of the checklist.
Anyone know what could be causing this?
Thank you!