import ipyaggrid
import json
import pandas as pd
dfm = pd.read_json("OlympicWinners.json")
column_defs = [{'field': c} for c in dfm.columns[:]]
grid_options = {
'columnDefs' : column_defs,
}
buttons = [
{'name':'Expand All', 'action':'''gridOptions.api.expandAll();'''},
{'name':'Collapse All', 'action':'''gridOptions.api.collapseAll();'''},
]
grid_options = {
'columnDefs' : column_defs,
# 'enableSorting': True,
# 'enableFilter': True,
# 'enableColResize': True,
# 'enableRangeSelection': True,
# 'groupDefaultExpanded':1,
# 'groupDisplayType':'multipleColumns',
# 'suppressAggFuncInHeader':True,
# 'groupRemoveLowestSingleChildren': False
}
# default_col_defs = {
# 'flex':1,
# 'resizable': True,
# 'wrapText': True,
# 'wrapHeaderText':True,
# 'autoHeight': True,
# 'autoHeaderHeight': True,
# "cellStyle": {"wordBreak": "normal"}
# }
# auto_group_column_def = {
# 'cellRendererParams' : {
# 'suppressCount': True,
# },
# }
agGridLicenseKey = "community"
page = ipyaggrid.Grid(
grid_data=dfm,
height=800,
theme='ag-theme-balham',
grid_options=grid_options,
quick_filter=True,
columns_fit='size_to_fit',
compress_data=True,
menu={'buttons':buttons},
license=agGridLicenseKey
)