Title: Feature Request: Support Fixed cellWidth with Automatic Column Calculation · Issue #3469 · gridstack/gridstack.js · GitHub
Open Graph Title: Feature Request: Support Fixed cellWidth with Automatic Column Calculation · Issue #3469 · gridstack/gridstack.js
X Title: Feature Request: Support Fixed cellWidth with Automatic Column Calculation · Issue #3469 · gridstack/gridstack.js
Description: Feature Request: Support Fixed cellWidth with Automatic Column CalculationBackgroundI'm using GridStack.js in my project to build a grid-based dashboard/layout system.Currently, the grid layout is primarily controlled by the number of co...
Open Graph Description: Feature Request: Support Fixed cellWidth with Automatic Column CalculationBackgroundI'm using GridStack.js in my project to build a grid-based dashboard/layout system.Currently, the grid layout is ...
X Description: Feature Request: Support Fixed cellWidth with Automatic Column CalculationBackgroundI'm using GridStack.js in my project to build a grid-based dashboard/layout system.Currently, the grid layout...
Opengraph URL: https://github.com/gridstack/gridstack.js/issues/3469
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature Request: Support Fixed cellWidth with Automatic Column Calculation","articleBody":"\u003chtml>\n\u003cbody>\n\u003c!--StartFragment-->\u003ch2>\u003cspan>Feature Request: Support Fixed \u003c/span>\u003ccode>\u003cspan>cellWidth\u003c/span>\u003c/code>\u003cspan> with Automatic Column Calculation\u003c/span>\u003c/h2>\u003ch3>\u003cspan>Background\u003c/span>\u003c/h3>\u003cp>\u003cspan>I'm using GridStack.js in my project to build a grid-based dashboard/layout system.\u003c/span>\u003c/p>\u003cp>\u003cspan>Currently, the grid layout is primarily controlled by the number of columns and the container width. While \u003c/span>\u003ccode>\u003cspan>column\u003c/span>\u003c/code>\u003cspan> and \u003c/span>\u003ccode>\u003cspan>columnOpts.columnWidth\u003c/span>\u003c/code>\u003cspan> provide some flexibility, I'd like to have more direct control over the cell width and let GridStack automatically determine the number of columns based on the available container width.\u003c/span>\u003c/p>\u003ch3>\u003cspan>Problem\u003c/span>\u003c/h3>\u003cp>\u003cspan>In my use case, I need the cell width to remain fixed regardless of the container width.\u003c/span>\u003c/p>\u003cp>\u003cspan>When the container is resized, I want the number of columns to automatically adjust based on the available space, rather than having the cell width change to fit the container.\u003c/span>\u003c/p>\u003cp>\u003cspan>For example:\u003c/span>\u003c/p>\u003cul>\u003cli>\u003cp>\u003cspan>If the container width is \u003c/span>\u003ccode>\u003cspan>1200px\u003c/span>\u003c/code>\u003cspan> and the cell width is \u003c/span>\u003ccode>\u003cspan>100px\u003c/span>\u003c/code>\u003cspan>, the grid should have approximately 12 columns.\u003c/span>\u003c/p>\u003c/li>\u003cli>\u003cp>\u003cspan>If the container width changes to \u003c/span>\u003ccode>\u003cspan>800px\u003c/span>\u003c/code>\u003cspan>, the grid should automatically adjust to approximately 8 columns.\u003c/span>\u003c/p>\u003c/li>\u003cli>\u003cp>\u003cspan>The cell width should remain \u003c/span>\u003ccode>\u003cspan>100px\u003c/span>\u003c/code>\u003cspan> in both cases.\u003c/span>\u003c/p>\u003c/li>\u003c/ul>\u003cp>\u003cspan>Currently, achieving this behavior requires custom logic to calculate the number of columns and update the grid accordingly.\u003c/span>\u003c/p>\u003ch3>\u003cspan>Proposed Feature\u003c/span>\u003c/h3>\u003cp>\u003cspan>Would it be possible to introduce a configurable \u003c/span>\u003ccode>\u003cspan>cellWidth\u003c/span>\u003c/code>\u003cspan> option that allows developers to specify a fixed cell width, while GridStack automatically calculates the number of columns based on the container width?\u003c/span>\u003c/p>\u003cp>\u003cspan>For example:\u003c/span>\u003c/p>\u003cpre>\u003ccode>\u003cspan>GridStack.init({\n cellWidth: 100,\n cellHeight: 80,\n column: 'auto'\n});\u003c/span>\u003c/code>\u003c/pre>\u003cp>\u003cspan>In this mode:\u003c/span>\u003c/p>\u003cul>\u003cli>\u003cp>\u003ccode>\u003cspan>cellWidth\u003c/span>\u003c/code>\u003cspan> remains fixed (e.g. \u003c/span>\u003ccode>\u003cspan>100px\u003c/span>\u003c/code>\u003cspan>).\u003c/span>\u003c/p>\u003c/li>\u003cli>\u003cp>\u003cspan>The number of columns is automatically calculated based on the container's available width.\u003c/span>\u003c/p>\u003c/li>\u003cli>\u003cp>\u003cspan>When the container is resized, the column count is recalculated automatically.\u003c/span>\u003c/p>\u003c/li>\u003cli>\u003cp>\u003cspan>The cell width does not shrink or expand to fill the container.\u003c/span>\u003c/p>\u003c/li>\u003c/ul>\u003cp>\u003cspan>Ideally, \u003c/span>\u003ccode>\u003cspan>cellWidth\u003c/span>\u003c/code>\u003cspan> could support pixel values and other CSS length units where appropriate.\u003c/span>\u003c/p>\u003ch3>\u003cspan>Expected Behavior\u003c/span>\u003c/h3>\u003cp>\u003cspan>Assuming \u003c/span>\u003ccode>\u003cspan>cellWidth\u003c/span>\u003c/code>\u003cspan> is set to \u003c/span>\u003ccode>\u003cspan>100px\u003c/span>\u003c/code>\u003cspan>:\u003c/span>\u003c/p>\nContainer Width | Expected Column Count | Cell Width\n-- | -- | --\n1200px | 12 | 100px\n1000px | 10 | 100px\n800px | 8 | 100px\n650px | 6 | 100px\n\n\u003cp>\u003cspan>The grid should automatically adjust the column count when the container width changes, while keeping the cell width fixed.\u003c/span>\u003c/p>\u003cp>\u003cspan>If the available width is not an exact multiple of \u003c/span>\u003ccode>\u003cspan>cellWidth\u003c/span>\u003c/code>\u003cspan>, the remaining space could be left unused, or handled according to the grid's existing alignment behavior.\u003c/span>\u003c/p>\u003ch3>\u003cspan>Use Cases\u003c/span>\u003c/h3>\u003cul>\u003cli>\u003cp>\u003cspan>Building dashboards with fixed-size grid cells.\u003c/span>\u003c/p>\u003c/li>\u003cli>\u003cp>\u003cspan>Maintaining consistent widget dimensions across different container sizes.\u003c/span>\u003c/p>\u003c/li>\u003cli>\u003cp>\u003cspan>Creating responsive layouts where the number of columns changes but the cell width remains constant.\u003c/span>\u003c/p>\u003c/li>\u003cli>\u003cp>\u003cspan>Avoiding custom resize handlers and manual column recalculation.\u003c/span>\u003c/p>\u003c/li>\u003cli>\u003cp>\u003cspan>Making grid layouts more predictable when embedded in different containers.\u003c/span>\u003c/p>\u003c/li>\u003c/ul>\u003ch3>\u003cspan>API Suggestion\u003c/span>\u003c/h3>\u003cp>\u003cspan>A possible API could be:\u003c/span>\u003c/p>\u003cpre>\u003ccode>\u003cspan>GridStack.init({\n cellWidth: 100,\n cellHeight: 80,\n column: 'auto'\n});\u003c/span>\u003c/code>\u003c/pre>\u003cp>\u003cspan>Alternatively, this could be implemented as an extension of the existing \u003c/span>\u003ccode>\u003cspan>columnOpts\u003c/span>\u003c/code>\u003cspan> configuration if that better fits GridStack's current API design.\u003c/span>\u003c/p>\u003ch3>\u003cspan>Additional Consideration\u003c/span>\u003c/h3>\u003cp>\u003cspan>It would be great if this behavior could work with GridStack's existing features, including drag-and-drop, resizing, responsive behavior, and layout serialization, without requiring users to implement their own container resize logic.\u003c/span>\u003c/p>\u003cp>\u003cspan>I understand that this may require changes to the grid's layout calculations. I'd appreciate feedback on whether this feature could be supported and what API design would be appropriate.\u003c/span>\u003c/p>\u003cp>\u003cspan>Thanks for maintaining GridStack.js!\u003c/span>\u003c/p>\u003c!--EndFragment-->\n\u003c/body>\n\u003c/html>","author":{"url":"https://github.com/zhangtian512","@type":"Person","name":"zhangtian512"},"datePublished":"2026-11-19T08:53:04Z","url":"https://github.com/gridstack/gridstack.js/issues/3469"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:eb91bf20-775b-2d2d-9ac1-7e456a485b83 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DCD2:9771F:10EF7C:169B77:6AFF4A7D |
| html-safe-nonce | 666d836d13aeab8b6c01b5b1d0c8d265f176ad54bb122d2ee132a1141a7c06ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0QyOjk3NzFGOjEwRUY3QzoxNjlCNzc6NkFGRjRBN0QiLCJ2aXNpdG9yX2lkIjoiMjM2NDk4OTI5MzQwNDgzNDQyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 41d3a3552bd376673670dcc2315edd01b9fd4773e622888e26f3062eb75acde4 |
| hovercard-subject-tag | issue:6485918572 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gridstack/gridstack.js/3469/issue_layout |
| twitter:image | https://opengraph.githubassets.com/49614c8aa863b2f425a5af9b2e679cdef9a6d459fe594e0c3bc217109551fa6b/gridstack/gridstack.js/issues/3469 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/49614c8aa863b2f425a5af9b2e679cdef9a6d459fe594e0c3bc217109551fa6b/gridstack/gridstack.js/issues/3469 |
| og:image:alt | Feature Request: Support Fixed cellWidth with Automatic Column CalculationBackgroundI'm using GridStack.js in my project to build a grid-based dashboard/layout system.Currently, the grid layout is ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zhangtian512 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6672a281260b126053da5da19a6127ba7804ee26f255c9b12ad124a822a55cd0 |
| turbo-cache-control | no-preview |
| go-import | github.com/gridstack/gridstack.js git https://github.com/gridstack/gridstack.js.git |
| octolytics-dimension-user_id | 31674162 |
| octolytics-dimension-user_login | gridstack |
| octolytics-dimension-repository_id | 26417283 |
| octolytics-dimension-repository_nwo | gridstack/gridstack.js |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 26417283 |
| octolytics-dimension-repository_network_root_nwo | gridstack/gridstack.js |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 28805d6cf6280f5e10f2a6624504c872d9633a0f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width