Skip to content

How to set a predefined height or width for “grid-stack-item” with acceptWidgets #918

@rafael-trevisan

Description

@rafael-trevisan

I'm using gridstack with acceptWidgets to drag-and-drop widgets from a left side panel to the main panel, kind of similar to http://gridstackjs.com/demo/two.html

In my case, I want to set height, width and other item attributes to my "grid-stack-item" so then when they're dropped they'd have some pre-defined height and width. However, setting up those attributes won't affect when the item is dropped in the gridstack.

Here is a JSFiddle: https://jsfiddle.net/trevisan/wt7bg6s1/8/

Note that the "Drag me" element has data-gs-width="6" which I expected to make it stretch as my gridstack has 6 columns.

<div class="grid-stack-item" data-gs-width="6">
  <div class="grid-stack-item-content">Drag me</div>
</div>

I have tried to call makeWidget method but then I end up having two widgets on my gridstack.

Does anyone have an idea how to figure that out?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions