Repository navigation
FAQ
Answers to the questions asked most often in the angular-gridster2 issues.
<gridster> fills its parent. Give the parent a height (height: 100vh, a flex layout, a fixed height), or use a grid type that sizes itself, see Grid Types.
Options are read when the options object changes. Assign a new object: this.options = { ...this.options, margin: 4 }.
Replace the item object and track items by id, see Items. To move other items out of the way use GridsterPush, see Push and Swap.
Store x, y, cols and rows of your items when itemChange fires, debounced. See Saving and Restoring Layouts.
Call the chart resize method on (itemResize), or observe the widget element with a ResizeObserver. See Dynamic Widgets.
Items have overflow: hidden, and with useTransformPositioning they are also the containing block of position: fixed elements. Render menus and dialogs in an overlay attached to <body> (Angular Material and the CDK do this by default) or set useTransformPositioning: false. See Styling.
The grid follows the size of its container, so it updates when the tab becomes visible. A grid created inside a hidden panel measures 0 and its items come out wrong, and it lays itself out correctly as soon as the panel is shown. With disableWindowResize: true the grid is not watched: call api.resize() when the container is shown. See Responsive and Mobile.
Put interactive content inside an element with the gridster-item-content class, use drag handles, or stop the mousedown/touchstart event. See Drag.
Use HTML5 drag and drop with enableEmptyCellDrop. See Empty Cells. Dragging items between two grids is not supported.
Leave enableEmptyCellDrop off to ignore drops. enableOccupiedCellDrop: true also fires the callbacks over existing items. itemValidateCallback can reject positions you do not allow.
An item overlaps another one or is outside the grid limits, so it was moved to the first free position. Check maxCols/maxRows and the item limits, or silence the warning with disableWarnings: true. See Items.
Not automatically: items are sized in grid cells. Measure the content and set rows accordingly, or make the content scroll inside the item.
Below mobileBreakpoint items are stacked in one column. For intermediate sizes switch options and layouts per breakpoint, see Responsive and Mobile.
From the Gridster component: columns, rows, curColWidth, curRowHeight. See API.
The library can be imported on the server, but the layout needs a browser to measure elements. Render the grid only in the browser, for example inside @defer or behind isPlatformBrowser.
Yes. The library works in zoneless applications and in applications that use zone.js.
Dispatch mousedown on the item, then mousemove and mouseup on document with clientX/clientY coordinates; for external drops dispatch dragover and drop on <gridster>.
With useTransformPositioning: true (the default) items are placed with transform: translate3d(). Depending on the screen scaling and on where the grid is on the page, browsers can draw that layer at fractional pixels and the text looks blurry (upstream #616). Set useTransformPositioning: false to place items with top/left instead; see Styling.
Set the scale option to the scale factor of the container (transform: scale(), CSS zoom or a pan and zoom library). Browser zoom needs nothing. See Responsive and Mobile.
Yes, a grid can be placed inside an item of another grid; the inner grid follows the size of its item.
curColWidth and curRowHeight are still 0 in initCallback, which runs before the first layout. Read them in itemInitCallback, in the item initCallback or in gridSizeChangedCallback, which run once the grid and its items have a size (upstream #624, #598).
No. The grid writes x, y, cols and rows into the item objects you pass it, so two grids over the same array, for example the same component shown in two tabs, overwrite each other's positions. Give each grid its own copy, such as items.map(item => ({ ...item })) (upstream #557).
MIT License. Originally created by Tiberiu Zuld as angular-gridster2. These pages are generated from the wiki/ folder of the repository: propose changes with a pull request.
Start
Guides
- Grid Types
- Grid Size and Margins
- Items
- Drag
- Resize
- Push and Swap
- Compaction
- Empty Cells
- Multi-Layer
- Responsive and Mobile
- RTL
- Dynamic Widgets
- Saving and Restoring Layouts
Reference
Help