gridstack.js icon indicating copy to clipboard operation
gridstack.js copied to clipboard

How to change the default width and height of grid stack placeholder?

Open jun1432 opened this issue 8 years ago • 14 comments

I'm referring to the dashed line when your dragging a widget.

jun1432 avatar Jun 29 '18 06:06 jun1432

For example the default value for now is data-gs-width="2" and data-gs-height="3". I want to change this to value. I'm thinking of having the data value of grid stack item's width and height.

I'm referring to the below classes. [css] .grid-stack .grid-stack-placeholder > .placeholder-content { border:1px dashed #d3d3d3; }

[html] {default values below} <div class="grid-stack-placeholder grid-stack-item" data-gs-x="0" data-gs-y="4" data-gs-width="2" data-gs-height="3"></div>

I want to edit these default values manually or dynamically. I hope I explained well my issue.

Thanks and more power.

jun1432 avatar Jun 29 '18 07:06 jun1432

Hi Guys,

For more info on the issue, below is a screenshot on the element that has this default value that I want to change.

http://www.screencast.com/t/OV3B53WBS

jun1432 avatar Jul 02 '18 11:07 jun1432

The value is the size of the widget. What are you trying to change it to?

radiolips avatar Jul 02 '18 13:07 radiolips

I want to change the default value of data-gs-width="6" and data-gs-height="4"

jun1432 avatar Jul 02 '18 13:07 jun1432

Those values are set to that because they're the values of the widget you're moving. The placeholder will always reflect the size of the widget.

radiolips avatar Jul 02 '18 13:07 radiolips

Thanks @radiolips.

jun1432 avatar Jul 02 '18 13:07 jun1432

Maybe related - how to change the granularity of "snap to" when resizing a widget?

ygalanter avatar Jul 17 '18 19:07 ygalanter

Those values are set to that because they're the values of the widget you're moving. The placeholder will always reflect the size of the widget.

@radiolips That doesn't seem true when you use the 'sidebar' of Two Grid Demo

How can you change the size in that case?

Hedva avatar Aug 07 '18 12:08 Hedva

@Hedva Also curious about this. That "drag me" item doesn't have any sizes specified, but becomes a 2x2 when dropping into either grid.

ermcgrat avatar Aug 08 '18 18:08 ermcgrat

Given that sidebar example of the two grid demo, I'm wondering if it is possible to achieve something similar to the Azure Portal. That is, the widget that you start dragging could be a different size than what it occupies in a grid. For example, all of the items are 1x1 in the sidebar but occupy something larger in the grid. Here is a screenshot for example, notice how the Clock item while being dragged occupies 2x2 on the grid, even though its ghosted image is smaller.

https://i.imgur.com/w2YrcmB.png

ermcgrat avatar Aug 08 '18 19:08 ermcgrat

We do this in our application. It’s entirely possible, but I’m on vacation so I have no way to access our code. I kind of remember we do the resizing on the gridstack ‘change’ event, when the widget is added to the grid. Sorry for the vague answer 😅

On Wed, 8 Aug 2018 at 21:31 ermcgrat [email protected] wrote:

Given that sidebar example of the two grid demo, I'm wondering if it is possible to achieve something similar to the Azure Portal. That is, the widget that you start dragging could be a different size than what it occupies in a grid. For example, all of the items are 1x1 in the sidebar but occupy something larger in the grid. Here is a screenshot for example, notice how the Clock item while being dragged occupies 2x2 on the grid, even though its ghosted image is smaller.

https://i.imgur.com/w2YrcmB.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gridstack/gridstack.js/issues/914#issuecomment-411524948, or mute the thread https://github.com/notifications/unsubscribe-auth/AAvG0qJD4Vjvb40gcu4bvQgH3Np1aw2xks5uOzyqgaJpZM4U8fCE .

lauantai avatar Aug 08 '18 21:08 lauantai

@lauantai I would be really grateful if you can provide an example in the near future. Can't figure it out yet

Hedva avatar Aug 13 '18 12:08 Hedva

Hey guys, I found a workaround that may be helpful if this issue still pertains to you

https://github.com/gridstack/gridstack.js/issues/933

ermcgrat avatar Aug 15 '18 19:08 ermcgrat

real fix in #1107 - sorry it took so long

adumesny avatar Dec 23 '19 16:12 adumesny