gridstack_move_widget
Reposition widgets within GridStack dashboards by specifying new X and Y coordinates to adjust layout organization.
Instructions
Move a widget to a new position
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| el | Yes | Widget selector or ID to move | |
| x | No | New X position | |
| y | No | New Y position |
Implementation Reference
- src/tools/index.ts:916-924 (handler)The primary handler function that implements the core logic for the 'gridstack_move_widget' tool. It destructures the input parameters (el, x, y) and generates the GridStack JavaScript code to move the widget using grid.move() via the utils.generateGridStackCode method.private async moveWidget(params: MoveWidgetParams): Promise<string> { const { el, x, y } = params; return this.utils.generateGridStackCode("moveWidget", { element: el, position: { x, y }, code: `grid.move('${String(el)}', ${x}, ${y});`, }); }
- src/tools/index.ts:236-257 (schema)The input schema definition for the gridstack_move_widget tool, specifying required 'el' parameter and optional 'x' and 'y' positions.{ name: "gridstack_move_widget", description: "Move a widget to a new position", inputSchema: { type: "object", required: ["el"], properties: { el: { type: "string", description: "Widget selector or ID to move", }, x: { type: "number", description: "New X position", }, y: { type: "number", description: "New Y position", }, }, }, },
- src/tools/index.ts:780-781 (registration)Registration and dispatching of the gridstack_move_widget tool in the callTool method's switch statement, casting args to MoveWidgetParams and calling the handler.case "gridstack_move_widget": return this.moveWidget(args as MoveWidgetParams);
- src/types.ts:194-198 (schema)TypeScript interface defining the input parameters for the moveWidget handler (el required, x and y optional).export interface MoveWidgetParams { el: string | HTMLElement; x?: number; y?: number; }
- src/utils/gridstack-utils.ts:16-27 (helper)Utility helper method used by the handler to format and generate the standardized response including code, description, example, and notes for the move operation.generateGridStackCode(operation: string, params: any): string { const result: GridStackCodeResult = { operation, parameters: params, code: params.code || "", description: this.getOperationDescription(operation), example: this.getOperationExample(operation), notes: this.getOperationNotes(operation), }; return this.formatResponse(result); }