Syntrex Claude Sonnet 4.6 commited on
Commit
2bcaea3
·
1 Parent(s): aea26b1

Use AgGrid flex to fill container proportionally without squishing columns

Browse files

fit_columns_on_grid_load shrinks all columns equally. flex distributes
remaining space proportionally to each column's weight so wider columns
stay wider, narrower columns stay narrower, and no scroll occurs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. visualization/betting_page.py +12 -2
visualization/betting_page.py CHANGED
@@ -378,13 +378,23 @@ def _render_sortable_grid(display_df: pd.DataFrame, numeric_df: pd.DataFrame, cs
378
  )
379
  gb.configure_column(style_field, hide=True)
380
  gb.configure_grid_options(headerHeight=38, rowHeight=36, suppressMovableColumns=True, suppressCellFocus=True, ensureDomOrder=True, animateRows=False)
 
 
 
 
 
 
 
 
 
 
381
  response = AgGrid(
382
  grid_df,
383
- gridOptions=gb.build(),
384
  allow_unsafe_jscode=True,
385
  custom_css=_GRID_THEME,
386
  theme="balham",
387
- fit_columns_on_grid_load=True,
388
  data_return_mode=DataReturnMode.FILTERED_AND_SORTED,
389
  update_mode=GridUpdateMode.MODEL_CHANGED,
390
  height=min(540, max(240, 86 + len(grid_df) * 36)),
 
378
  )
379
  gb.configure_column(style_field, hide=True)
380
  gb.configure_grid_options(headerHeight=38, rowHeight=36, suppressMovableColumns=True, suppressCellFocus=True, ensureDomOrder=True, animateRows=False)
381
+ grid_options = gb.build()
382
+ for col_def in grid_options.get("columnDefs", []):
383
+ field = col_def.get("field", "")
384
+ if field.startswith("__"):
385
+ continue
386
+ col_w = _COL_WIDTHS.get(field, _BOOK_COL_WIDTH)
387
+ col_def["flex"] = col_w
388
+ col_def["minWidth"] = max(50, col_w // 2)
389
+ col_def.pop("width", None)
390
+ col_def.pop("maxWidth", None)
391
  response = AgGrid(
392
  grid_df,
393
+ gridOptions=grid_options,
394
  allow_unsafe_jscode=True,
395
  custom_css=_GRID_THEME,
396
  theme="balham",
397
+ fit_columns_on_grid_load=False,
398
  data_return_mode=DataReturnMode.FILTERED_AND_SORTED,
399
  update_mode=GridUpdateMode.MODEL_CHANGED,
400
  height=min(540, max(240, 86 + len(grid_df) * 36)),