Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Can I pre-populate the filter query for a column in a DataTable that the user can subsequently change, delete, etc?

$
0
0

@davidhill wrote:

I would like to have a datatable that contains all data retrieved from my database, but upon first page load, is filtered by a pre-populated client-side filter visible to the user. I tried to hardcode something like the following unsuccessfully. Can I use the filter_query as a first line item under the datatable creation or is it only available for things like conditional formating, etc.?

                dash_table.DataTable(
                    id='dba-scheduler-status-table',
                    columns=[
                        {"name": i, "id": i} for i in dba_scheduler_output.columns
                    ],
                    data=dba_scheduler_output.to_dict("rows"),
                    editable=False,
                    filter_action='native',

                    filter_query='{OUTPUT} eq "DATAAGGRUNID 85"}',

                    sort_action='none',
                    row_deletable=False,
                    style_table={'overflowX': 'scroll' },
                    style_as_list_view=True,
                    style_cell={
                        'minWidth': '120px', 
                        'whiteSpace': 'no-wrap',
                        'overflow': 'hidden',
                        'textOverflow': 'ellipsis',
                    },
                    style_data={'backgroundColor': lightcolor,
                                'border': '0px solid white',
                                'fontColor': 'black',
                                'borderTop': '2px solid ' + darkcolor,
                                },
                    style_header={
                        'backgroundColor': lightcolor,
                        'fontWeight': 'bold',
                        'border': '0px solid white',
                        },
                    style_data_conditional=[
                        {
                        'if': { 'column_id': 'Comment' },
                        'textAlign': 'left',
                        },
                    ],
                    css=[{
                        'selector': '.dash-cell div.dash-cell-value',
                        'rule': 'display: inline; white-space: inherit; overflow: inherit; text-overflow: inherit;'
                        }],
                ),

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles