plotly / dash-table-experiments

NO LONGER SUPPORTED - use https://github.com/plotly/dash-table instead
MIT License
174 stars 57 forks source link

Resetting Filter State #65

Open scott-arne opened 6 years ago

scott-arne commented 6 years ago

I'm using a function to create a table in a div:

def generate_annotations_table(sort_column=None, sort_direction=None, filters={}):
    """
    Generate the annotations table
    """
    print("Refreshing table...")
    df = get_all_annotation_data()
    return dt.DataTable(
        rows=df.to_dict('records'),
        columns=['Col1', 'Col2', 'Col3'],
        editable=False,
        row_selectable=True,
        filterable=True,
        sortable=True,
        selected_row_indices=[],
        sortColumn=sort_column,
        sortDirection=sort_direction,
        filters=filters,
        id='datatable-annotations'
    )

When have new data, it just refreshes the div. I managed to find the sortColumn and sortDirection properties to preserve any sorting, which was nice. The problem is that I can't seem to preserve filtering using the filters property. Also, if I reset the filters with filter={} in the DataTable, the active filters on the table reset but the text typed by the user still remains in the filter box(es) at the top of the table.