MCPcopy Index your code
hub / github.com/plotly/dash / get_app

Function get_app

components/dash-table/tests/selenium/test_selected_rows_custom.py:16–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14
15
16def get_app():
17 app = dash.Dash(__name__)
18
19 app.layout = html.Div(
20 [
21 DataTable(
22 id="table",
23 columns=[{"name": i, "id": i} for i in rawDf.columns],
24 data=df,
25 row_selectable="multi",
26 selected_rows=[],
27 filter_action="custom",
28 filter_query="",
29 sort_action="custom",
30 sort_by=[],
31 page_action="custom",
32 page_current=0,
33 page_size=10,
34 style_cell=dict(width=100, min_width=100, max_width=100),
35 ),
36 html.Button("Set selected + sort_by", id="sort"),
37 html.Button("Set selected + filter", id="filter"),
38 html.Button("Set selected + page", id="page"),
39 html.Div(id="selected_rows_output"),
40 ]
41 )
42
43 @app.callback(
44 Output("selected_rows_output", "children"),
45 Input("table", "selected_rows"),
46 )
47 def show_selected_rows(selected_rows):
48 return json.dumps(selected_rows) if selected_rows is not None else "None"
49
50 @app.callback(
51 Output("table", "selected_rows"),
52 Output("table", "sort_by"),
53 Input("sort", "n_clicks"),
54 prevent_initial_call=True,
55 )
56 def set_selected_and_sort(_):
57 return [0, 1, 2], [{"column_id": rawDf.columns[0], "direction": "asc"}]
58
59 @app.callback(
60 Output("table", "selected_rows", allow_duplicate=True),
61 Output("table", "filter_query"),
62 Input("filter", "n_clicks"),
63 prevent_initial_call=True,
64 )
65 def set_selected_and_filter(_):
66 return [0, 1, 2], "{} > 1".format(rawDf.columns[0])
67
68 @app.callback(
69 Output("table", "selected_rows", allow_duplicate=True),
70 Output("table", "page_current"),
71 Input("page", "n_clicks"),
72 prevent_initial_call=True,
73 )

Calls 1

DataTableClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…