My objective is to make pMain fill the remainder of the screen, using height=100% obviously won’t work because 100% is 100% of the whole layout ie. pMain actually needs to be
total layout height - (header height + toolbar height)
A suggested approach is to set the div to 80% height but this is a bad choice because it will look different depending on the screen size. The only way I have found to do this is is to explicitly set the height for pMain:
height: (window.innerHeight - 90)+"px"
//I arrived at '90' by trail and error
Does anyone have a better idea about how to do this?
var layout = new dhx.Layout("divLayout", {
height: window.innerHeight,
width: "100%",
rows: [
{id:"toolbar-cell"},
{id:"grid-cell"}
]
});
When I attach a toolbar to the toolbar-cell, the rest of the available space is dedicated to grid-cell. So from what you’ve posted, I don’t think you need to be doing the height calculation at all.
Thanks for the reply, your approach does seem to work but only when there are two rows and also the height of the layout would need to be set again if the screen is resized.
My original post is simplified as I actually have 3 rows, when using your approach it seems to spread the height evenly across all 3:
I tried setting explicit heights on 2 of the rows thinking that the 3rd would then have the leftover space but strangely that seemed to have no effect:
I understand your frustration. What’s catching you here is the “gravity” setting, and it’s something I’m still working on wrapping my head around also. Assigning gravity: true (note: it’s true by default, so you have to explicitly turn it off by setting to false if you don’t want it) to rows causes them to distribute as evenly as possible in the available space. I’ve modified your second snippet to show you the difference it makes when you set the gravity to false for the rows you want to set explicit heights for.
Setting gravity to false is not a complete solution of this issue. Problem is in flexible nature (display:flex) of Layout and it’s Cells. When you resize window, height of Cells will be recalculated and still little bit changed. My solution is to set real fixed height for toolbar’s Cell: