gridstack_remove_widget
Remove widgets from dashboard grids by specifying their selector or ID, with options to delete from DOM and trigger removal events.
Instructions
Remove a widget from the grid
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| el | Yes | Widget selector or ID to remove | |
| removeDOM | No | Remove from DOM as well | |
| triggerEvent | No | Trigger 'removed' event |
Implementation Reference
- src/tools/index.ts:178-201 (schema)Defines the input schema, description, and parameters for the gridstack_remove_widget tool.{ name: "gridstack_remove_widget", description: "Remove a widget from the grid", inputSchema: { type: "object", required: ["el"], properties: { el: { type: "string", description: "Widget selector or ID to remove", }, removeDOM: { type: "boolean", description: "Remove from DOM as well", default: true, }, triggerEvent: { type: "boolean", description: "Trigger 'removed' event", default: true, }, }, }, },
- src/tools/index.ts:774-775 (registration)Registers the tool name to its handler function in the central callTool switch dispatcher.case "gridstack_remove_widget": return this.removeWidget(args as RemoveWidgetParams);
- src/tools/index.ts:893-904 (handler)The primary handler function that destructures input params and generates executable GridStack JavaScript code to remove the widget using GridStack.removeWidget.private async removeWidget(params: RemoveWidgetParams): Promise<string> { const { el, removeDOM = true, triggerEvent = true } = params; return this.utils.generateGridStackCode("removeWidget", { element: el, removeDOM, triggerEvent, code: `grid.removeWidget('${String( el )}', ${removeDOM}, ${triggerEvent});`, }); }
- src/types.ts:183-187 (schema)TypeScript interface defining the type signature for removeWidget parameters, matching the JSON schema.export interface RemoveWidgetParams { el: string | HTMLElement; removeDOM?: boolean; triggerEvent?: boolean; }