gridstack_add_grid
Create a new dynamic grid layout with customizable widgets and options for building responsive dashboards using GridStack.js functionality.
Instructions
Create a new grid with options and children (static method)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parent | Yes | Parent element selector | |
| opt | No | Grid options including children |
Implementation Reference
- src/tools/index.ts:1157-1169 (handler)The handler function that implements the core logic for the 'gridstack_add_grid' tool. It extracts parameters and generates JavaScript code using GridStackUtils to call the static GridStack.addGrid method, creating a new grid instance.private async addGrid(params: any): Promise<string> { const { parent, opt = {} } = params; return this.utils.generateGridStackCode("addGrid", { parent, options: opt, code: `const grid = GridStack.addGrid('${parent}', ${JSON.stringify( opt, null, 2 )});`, }); }
- src/tools/index.ts:733-761 (schema)The input schema and tool definition for 'gridstack_add_grid', defining required parameters like parent selector and optional grid options.{ name: "gridstack_add_grid", description: "Create a new grid with options and children (static method)", inputSchema: { type: "object", required: ["parent"], properties: { parent: { type: "string", description: "Parent element selector", }, opt: { type: "object", description: "Grid options including children", properties: { children: { type: "array", items: { type: "object", description: "Child widget configuration", }, description: "Array of child widgets to load", }, }, }, }, }, },
- src/tools/index.ts:855-856 (registration)Registration of the tool handler in the central callTool switch statement, dispatching calls to the addGrid method.case "gridstack_add_grid": return this.addGrid(args);