Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

followup aggrid state opti #1125

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions docs/library/tables-and-data-grids/ag_grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,21 +416,27 @@ import pandas as pd

class AgGridState(rx.State):
"""The app state."""
all_columns = [
ag_grid.column_def(field="country"),
ag_grid.column_def(field="pop"),
ag_grid.column_def(field="continent"),
ag_grid.column_def(field="lifeExp"),
ag_grid.column_def(field="gdpPercap"),
]

two_columns = [
ag_grid.column_def(field="country"),
ag_grid.column_def(field="pop"),
]
column_defs = all_columns
all_columns: list = []

two_columns: list = []
column_defs: list = all_columns
n_clicks = 0

@rx.event
def init_columns(self):
self.all_columns = [
ag_grid.column_def(field="country"),
ag_grid.column_def(field="pop"),
ag_grid.column_def(field="continent"),
ag_grid.column_def(field="lifeExp"),
ag_grid.column_def(field="gdpPercap"),
]
self.two_columns = [
ag_grid.column_def(field="country"),
ag_grid.column_def(field="pop"),
]
self.column_defs = self.all_columns

@rx.event
def update_columns(self):
self.n_clicks += 1
Expand All @@ -450,6 +456,7 @@ def ag_grid_simple_with_state():
id="ag_grid_basic_with_state",
row_data=df.to_dict("records"),
column_defs=AgGridState.column_defs,
on_mount=AgGridState.init_columns,
width="100%",
height="40vh",
),
Expand Down
Loading