Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions nicegui/elements/aggrid/aggrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ export default {
return runMethod(this.api.getRowNode(row_id), name, args);
},
handle_event(type, args) {
if (type === "gridSizeChanged" && this.auto_size_columns) {
this.api.sizeColumnsToFit();
}
this.$emit(type, {
value: args.value,
oldValue: args.oldValue,
Expand Down Expand Up @@ -114,6 +111,5 @@ export default {
props: {
options: Object,
html_columns: Array,
auto_size_columns: Boolean,
},
};
14 changes: 10 additions & 4 deletions nicegui/elements/aggrid/aggrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ def __init__(self,
:param auto_size_columns: whether to automatically resize columns to fit the grid width (default: ``True``)
"""
super().__init__()
self._props['options'] = {'theme': theme or 'quartz', **options}
self._props['options'] = {
'theme': theme or 'quartz',
**({'autoSizeStrategy': {'type': 'fitGridWidth'}} if auto_size_columns else {}),
**options,
}
self._props['html_columns'] = html_columns[:]
self._props['auto_size_columns'] = auto_size_columns
self._update_method = 'update_grid'

@classmethod
Expand Down Expand Up @@ -149,11 +152,14 @@ def theme(self, value: Optional[Literal['quartz', 'balham', 'material', 'alpine'
@property
def auto_size_columns(self) -> bool:
"""Whether to automatically resize columns to fit the grid width."""
return self._props['auto_size_columns']
return self._props['options'].get('autoSizeStrategy', {}).get('type') == 'fitGridWidth'

@auto_size_columns.setter
def auto_size_columns(self, value: bool) -> None:
self._props['auto_size_columns'] = value
if value and not self.auto_size_columns:
self._props['options']['autoSizeStrategy'] = {'type': 'fitGridWidth'}
if not value and self.auto_size_columns:
self._props['options'].pop('autoSizeStrategy')

def run_grid_method(self, name: str, *args, timeout: float = 1) -> AwaitableResponse:
"""Run an AG Grid API method.
Expand Down