How fix updating

Here you go:

import dash_bootstrap_components as dbc
from dash import Dash, html, dcc, Input, Output, State, callback_context, no_update, callback, exceptions
import dash_ag_grid as dag


app = Dash(external_stylesheets=[dbc.themes.BOOTSTRAP], update_title=None)

lpu_list = [{'option': f'lpu{lpu}'} for lpu in range(10)]

app.layout = html.Div([
    html.Div(
        html.Div(
            [
                html.Div(
                    id='view',
                    style={
                        'display': 'flex',
                        'height': '38px',
                        'width': '29vw',
                        'border': '1px solid',
                        'padding-right': '5px',
                        'textAlign': 'center',
                        'overflow': 'hidden',
                        'font-size': '20px'
                    },
                ),
                dbc.DropdownMenu(
                    id="dropdown-menu",
                    align_end=True,
                    children=[
                        html.Div(
                            id='select_all', className='noselect', children=html.Div(
                            children=[html.Img(src="/assets/bx-list-check.svg"),
                             html.Span("Выбрать все"),
                                ]
                            ),
                        ),
                        html.Div(
                            [
                                dcc.Input(
                                    id="search-input",
                                    type="text",
                                    placeholder="Type to filter",
                                    autoComplete="off",
                                    style={'margin-left': '.5rem'},
                                    debounce=False
                                ),
                            ],
                            id="input-container",
                        ),
                        dbc.DropdownMenuItem(divider=True),
                        dag.AgGrid(
                            id='checklist',
                            columnDefs=[{'field': 'option', 'checkboxSelection': True,
                                         'headerCheckboxSelection': True, 'headerName': ''}],
                            rowData=lpu_list,
                            persistence_type='session',
                            persistence=True,
                            dashGridOptions={'rowSelection': 'multiple',
                                             'rowMultiSelectWithClick': True,
                                             "headerCheckboxSelectionFilteredOnly": True,
                                             # 'headerHeight': 0
                                             }
                        ),
                    ]
                ),
                html.Div(id='output_div')
            ],
            className='selector_containerFinal',
            style={
                'justify-content': 'center'
            },
        ),
    ),
])


app.clientside_callback(
    """function () {return true}""",
    Output('checklist', 'selectAll'),
    Input('select_all', 'n_clicks'),
    prevent_initial_call=True
)

app.clientside_callback(
    """function (v) { return v}""",
    Output("checklist", "quickFilterText"),
    Input("search-input", "value"),
    prevent_initial_call=True
)

if __name__ == '__main__':
    app.run(debug=True)

How about no post requests? :stuck_out_tongue:

3 Likes