Skip to content

Latest commit

 

History

History
96 lines (62 loc) · 2.52 KB

File metadata and controls

96 lines (62 loc) · 2.52 KB

base-widget

Classes

abstract BaseWidget

Defined in: angular/projects/lib/src/lib/base-widget.ts:39

Base widget class for GridStack Angular integration.

Constructors

Constructor
new BaseWidget(): BaseWidget;
Returns

BaseWidget

Methods

serialize()
serialize(): undefined | NgCompInputs;

Defined in: angular/projects/lib/src/lib/base-widget.ts:66

Override this method to return serializable data for this widget.

Return an object with properties that map to your component's @Input() fields. The selector is handled automatically, so only include component-specific data.

Returns

undefined | NgCompInputs

Object containing serializable component data

Example
serialize() {
  return {
    title: this.title,
    value: this.value,
    settings: this.settings
  };
}
deserialize()
deserialize(w): void;

Defined in: angular/projects/lib/src/lib/base-widget.ts:88

Override this method to handle widget restoration from saved data.

Use this for complex initialization that goes beyond simple @Input() mapping. The default implementation automatically assigns input data to component properties.

Parameters
Parameter Type Description
w NgGridStackWidget The saved widget data including input properties
Returns

void

Example
deserialize(w: NgGridStackWidget) {
  super.deserialize(w); // Call parent for basic setup

  // Custom initialization logic
  if (w.input?.complexData) {
    this.processComplexData(w.input.complexData);
  }
}

Properties

Property Modifier Type Description Defined in
widgetItem? public NgGridStackWidget Complete widget definition including position, size, and Angular-specific data. Populated automatically when the widget is loaded or saved. angular/projects/lib/src/lib/base-widget.ts:45