Skip to content
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

grid items to take entire parent height (simulate % rows, like columns do) #787

Open
adumesny opened this issue Sep 19, 2017 · 15 comments
Open

Comments

@adumesny
Copy link
Member

adumesny commented Sep 19, 2017

I'm using nested grids to create compound widgets - tight group of widgets, that can be used as opaque widgets inside other grids (moved as a unit, edited separately). As such I need a nested items to take entire space (width AND height) given by the parent gridItem, which will have user resizable heuristics.

Ideally I would have a grid.cellHeight = 'dynamic' mean take entire height of the parent, similar to what we have today with columns taking entire width (% based sizing). Adding a new item would temporally create new rows (create scroll V bars as content won't fit) as you drag/position things around, but then size to fit as you release (shrink the cellHeight to fit, keeping same rows# and overall layout)

for now I'm trying to hack in on the side.... not working the simplest part yet!

Your environment

v 0.3.0 and latest 1.0.0-dev showing slightly different behavior (due to

Steps to reproduce

  1. https://jsfiddle.net/cLdzzL8p/2/
    is a copy of demo/nested.html with additional code to handle item resize
    $('#grid').on('gsresizestop')
  2. pretend to resize the griditem on right (nested) or just make it wider to trigger event
  3. oldCellHeight = 60px should go to larger number (140px for same 300pix gridItem)

Expected behaviour

nested grid to take entire height of parent (dynamically changing)

Actual behaviour

in v0.3.0 (gridster sample) the grid DOES grow and take entire height, forcing cells to get taller as well, BUT all the siblings gridItems also grow (making me thing either it's an incorrect shared resource or the $() search is not filtered to children of nested grid.

in 1.0.0-dev (the one I use) noting seems to appears as GridStack.prototype._updateStyles() returns early due to this line of code that was moved ealier

if (this._styles._max !== 0 && maxHeight <= this._styles._max) { return; } // Keep this._styles._max increasing

see a38d78e which I don't understand. #766 as well

@adumesny
Copy link
Member Author

adumesny commented Sep 20, 2017

same/related to #717 #728 #118 #404 and probably many others... would be ideal to have cellHeight = "dynamic" as a way to support grid take 100% of parent height (triggering resize events on parent might not be trivial and container specific. in my case it's another griditem/div, but it could be outer window/div), while allowing add/remove and dragging of items in that allowed space.

@krilllind
Copy link

@argument Or you could set the height to X amount of rows and then gridstack would use the height of itself or parent to split into X rows. That way it would work the same way as width does now.

Then only specify verticalMargin if you want spacing between each row. For auto expanding height behaviour, you could set height to "auto" instead?

@adumesny
Copy link
Member Author

adumesny commented Sep 20, 2017

Or you could set the height to X amount of rows and then gridstack would use the height of itself or parent to split into X rows

@krilllind if you have fixed # of column (12) and rows then you can't really add/remove content without sizing them down and you still have an absolute max. height today should really be maxHeight (or `maxRow') as it specifies the max number of rows you can have, so it sort of does what you suggest.

This and the other request are to have grid fill the available height provided by parent, but still let you interact/add/remove items.

@nissimpradhan
Copy link

Have you made any progress on this issue? I have this problem as well as several others. Here's the new issue that i made. # #814

@Altraya
Copy link

Altraya commented Dec 9, 2019

Have you planned to release this in a new version soon ?
I've made a special patch for my own need but it's not satisfying and it include other bugs in my version.
I am really looking to a lasting solution for this.

@adumesny
Copy link
Member Author

adumesny commented Dec 9, 2019

@Altraya I have not looked at a fix but would love to have someone submit a code review for this!

@adumesny
Copy link
Member Author

ironically I own the lib now but have not looked at my early request as my needs have changed since then... :)

@digitalml
Copy link

digitalml commented Jul 28, 2022

@adumesny was this ever completed ? i'm not using nested grids but i've read through all the other issues... I'm trying to achieve can the height of a grid be 100vh and resize the inner items to always stay within that height so the user never has to scroll ?

Edit: @adumesny - After Reading other threads it seems that I might be able to hire you to help with this issue? Please let me know. Thank you!

@adumesny
Copy link
Member Author

adumesny commented Sep 6, 2022

yes, donation are always welcomed. v6 has been released so I'm available to work on features again... ping me directly

@adumesny adumesny changed the title support for nested grid to take entire parent height (simulate % rows, like columns do) grid items to take entire parent height (simulate % rows, like columns do) Sep 17, 2022
@boskiv
Copy link

boskiv commented Sep 18, 2023

Hi, how it's going on that issue? Is it possible to have 100vh grid with auto scalable items inside?

@adumesny
Copy link
Member Author

adumesny commented Sep 18, 2023

not going to happen (I don't need it for work) unless someone wants to support it... not an easy feature.

@adumesny
Copy link
Member Author

(sub)-grid would look like this (yellow being 'full screen') with each component number representing # of rows (h) as you add/resize items. not matter what you bring in (how tall h) it will eventually scale all to fit into 100vh (or other) grid. so technically row are changing % to the min/max/current always fit 100% of the container

image
image
image
image

@0uk
Copy link

0uk commented Feb 9, 2024

Hi,

As I was trying to achieve the same thing I gave the following a go:

In the CSS:

.grid-stack {
  display: block;
  overflow: hidden;
  height: 100%;
  min-height: 100% !important;
}

and in the JS:

const N_COLS = 12;
const N_ROWS = 12;
var grid = GridStack.init({
    column: N_COLS,
    cellHeight: 100 / N_ROWS,
    cellHeightUnit: "%",
    maxRow: N_ROWS
});

Unless I have missed something, it seems to achieve the desired behaviour with no change to the gridstack code.

@adumesny
Copy link
Member Author

adumesny commented Feb 9, 2024

ok good to know. didn't think cellHeight:10% worked. glad it is. even if you resize the window ?

@gosongying
Copy link

gosongying commented Aug 5, 2024

Hi, for the nested grid demo https://gridstackjs.com/demo/nested.html#, may I know which part makes the second nested grid to be taking the full height of its parent? I have followed the code, but on my end, the nested grid still can't take up its parent's full height.

My second approach is using addWidget to add sub grid, by that way, the sub grid cannot take up the full height of its parent's, do you have any suggestion on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants