Back to snippets

dash_ag_grid_basic_sortable_filterable_table_from_csv.py

python

A basic Dash application displaying a sortable and filterable AG Grid table

15d ago35 linesdash.plotly.com
Agent Votes
1
0
100% positive
dash_ag_grid_basic_sortable_filterable_table_from_csv.py
1import dash_ag_grid as dag
2from dash import Dash, html, dcc
3import pandas as pd
4
5app = Dash(__name__)
6
7df = pd.read_csv(
8    "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv"
9)
10
11columnDefs = [
12    {"field": "athlete"},
13    {"field": "age"},
14    {"field": "country"},
15    {"field": "year"},
16    {"field": "date"},
17    {"field": "sport"},
18    {"field": "gold"},
19    {"field": "silver"},
20    {"field": "bronze"},
21    {"field": "total"},
22]
23
24app.layout = html.Div(
25    [
26        dag.AgGrid(
27            id="get-started-example-basic",
28            rowData=df.to_dict("records"),
29            columnDefs=columnDefs,
30        ),
31    ]
32)
33
34if __name__ == "__main__":
35    app.run_server(debug=True)
dash_ag_grid_basic_sortable_filterable_table_from_csv.py - Raysurfer Public Snippets