-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
How to make cellHeight fill container height #2583
Comments
By setting grid.cellHeight = 600 / 4 (number of rows). It seems working... is there a way to do it automatically ? "auto" doesn't work.. If I set row = 4, column = 4 even without item in the grid, the height of .grid-stack is set to 1302px ? My grid options :
The html result :
Maybe the question is why the .grid-stack height is set to 1302px ? |
related to #787 |
@ptorrent find the parent element of the grid and set the font size dividing the height by the count of the rows available in the grid. Execute it after view initialization.
call the method each time the window size changes |
I have the same need for my situation. This code worked for me: you need to know the total height of the full gridstack, which is always the largest Call this when the window size or layout changes. Note the resizeToFillVertical(parentId: string) {
const parentElement = document.getElementById('parentId')
if (!parentElement) return
const totalGridHeight = this.grid.getGridItems().reduce((a,b) => {
return Math.max(a, b.gridstackNode.y + b.gridstackNode.h)
}, 0)
const height = parentElement.clientHeight
const newCellHeight = Math.floor(height / totalGridHeight)
this.grid.cellHeight(`${newCellHeight}px`)
}
|
@billyc no need to find the row count yourself. just call |
Ah! thanks @adumesny, that definitely makes my code a bit simpler. I don't see Thank you so much for maintaining this library -- it does exactly what I need! 🙏 |
the doc is not auto generated from code - need to change that - so it can be out of date/missing sometimes... |
Hello there,
How to create a checkboarder with a fixed container height (without scroll). How to make rows working exactly like column ?
Example:
column : 3
row : 2
with 6 items
Column : 3
row : 2
with 3 items
colum : 3
row : 3
with 3 items
colum : 3
row : 3
with 2 items
Actually it's working well for column. If I set column = 3 and I've only 2 item, the size of items are correct. There is an empty space for the 3th item. But we don't have the same behavior for rows...
Container width and height always the same : 800x600
The text was updated successfully, but these errors were encountered: