Closed gioxc88 closed 1 year ago
Full height of what? Can you provide a bit more context?
Full height of what? Can you provide a bit more context?
In the documentation, under dimension and placement, it is possible to specify width='100%'
so that the grid takes all the horizontal space available, it's not possible to do the same for height.
also in the angular doc it seems that there is a parameter called domLayout={'autoHeight'}
which is not available in the python api. Would it be too difficult to add?
https://www.ag-grid.com/react-data-grid/grid-size/#grid-auto-height
I am basically looking for a way to make the grid take only the space required to show all the rows and columns automatically
thanks
Thanks for the clarification!
"domLayout": "autoHeight"
seems to work in grid_options
. The height is then still limited by the default height, which can be fixed by setting grid.height
to -1
.
Example:
import json
import urllib.request as ur
from ipyaggrid import Grid
url = "https://www.ag-grid.com/example-assets/olympic-winners.json"
with ur.urlopen(url) as res:
data = json.loads(res.read().decode("utf-8"))[:100]
columnDefs = [
{"headerName": "Country", "field": "country"},
{"headerName": "Year", "field": "year"},
{"headerName": "Sport", "field": "sport"},
{"headerName": "Athlete", "field": "athlete"},
{"headerName": "Gold", "field": "gold"},
]
gridOptions = {
"enableColResize": True,
"columnDefs": columnDefs,
"enableSorting": True,
"defaultColDef": {"sortable": True},
"domLayout": "autoHeight",
}
grid1 = Grid(quick_filter=True,
theme="ag-theme-balham",
compress_data=True,
grid_options=gridOptions,
grid_data=data,
columns_fit="auto",
height=-1)
grid1
@mariobuikhuizen is the height=-1 an aggrid or ipyaggrid thing?
It's an ipyaggrid thing. Where the height is an int with 350 as default. Setting it to -1 so no height is set is a bit of a hack actually.
Yes, Optional[int] would have been more intuitive.
That works thanks a lot.
The only problem I see is that when you use the agSetColumnFilter
and uncheck Select all
it shrinks, making it difficult to operate
I see. We may need to add more style options (e.g. min-height ).
A workaround would be to use thecss_rules
of Grid
:
Grid(css_rules="""
.ag-root-wrapper .ag-layout-auto-height {
min-height: 200px;
}
""",
...
Closing this as answered.
is it possible to figure make the grid full height? I couldn't find anything in the doc
Thanks