# GridAdapter

> _Since v0.11.0_

## Methods

### processGridConfig()

Processes an Angular grid configuration, converting component class references
to actual renderer/editor functions.

Call this method on your gridConfig before passing it to the grid.

```ts
processGridConfig(config: GridConfig<TRow>): GridConfig<TRow>
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `config` | <code><a href="/grid/angular/api/types/gridconfig/">GridConfig</a>&lt;TRow&gt;</code> | Angular grid configuration with possible component class references |

#### Returns

`GridConfig<TRow>` - Processed GridConfig with actual renderer/editor functions

***

### processConfig()

FrameworkAdapter.processConfig implementation.
Called automatically by the grid's `set gridConfig` setter.

```ts
processConfig(config: GridConfig<TRow>): GridConfig<TRow>
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `config` | <code><a href="/grid/angular/api/types/gridconfig/">GridConfig</a>&lt;TRow&gt;</code> |  |

***

### processTypeDefaults()

Processes typeDefaults configuration, converting component class references
to actual renderer/editor functions.

```ts
processTypeDefaults(typeDefaults: Record<string, TypeDefault<TRow>>): Record<string, BaseTypeDefault<TRow>>
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `typeDefaults` | <code>Record&lt;string, <a href="/grid/angular/api/types/typedefault/">TypeDefault</a>&lt;TRow&gt;&gt;</code> | Angular type defaults with possible component class references |

#### Returns

`Record<string, BaseTypeDefault<TRow>>` - Processed TypeDefault record

***

### processColumn()

Processes a single column configuration, converting component class references
to actual renderer/editor functions.

```ts
processColumn(column: ColumnConfig<TRow>): ColumnConfig<TRow>
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `column` | <code><a href="/grid/angular/api/types/columnconfig/">ColumnConfig</a>&lt;TRow&gt;</code> | Angular column configuration |

#### Returns

`ColumnConfig<TRow>` - Processed ColumnConfig

***

### canHandle()

Determines if this adapter can handle the given element.
Checks if a template is registered for this element (structural or nested).

```ts
canHandle(element: HTMLElement): boolean
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `element` | <code>HTMLElement</code> |  |

***

### createRenderer()

Creates a view renderer function that creates an embedded view
from the registered template and returns its DOM element.

Returns undefined if no template is registered for this element,
allowing the grid to use its default rendering.

```ts
createRenderer(element: HTMLElement): ColumnViewRenderer<TRow, TValue> | undefined
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `element` | <code>HTMLElement</code> |  |

***

### createEditor()

Creates an editor spec that creates an embedded view.

**Auto-wiring**: The adapter automatically listens for `commit` and `cancel`
CustomEvents on the rendered component. If the component emits these events,
the adapter will call the grid's commit/cancel functions automatically.

This means templates can be simplified from:
```html
<app-editor *tbwEditor="let value; onCommit as onCommit"
  [value]="value" (commit)="onCommit($event)" />
```
To just:
```html
<app-editor *tbwEditor="let value" [value]="value" />
```
As long as the component emits `(commit)` with the new value.

```ts
createEditor(element: HTMLElement): ColumnEditorSpec<TRow, TValue> | undefined
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `element` | <code>HTMLElement</code> |  |

***

### createDetailRenderer()

Creates a detail renderer function for MasterDetailPlugin. Delegates to
the bridge installed by `@toolbox-web/grid-angular/features/master-detail`.
Returns undefined if the feature is not imported or no `<tbw-grid-detail>`
template is registered for this grid.

```ts
createDetailRenderer(gridElement: HTMLElement): (row: TRow) => HTMLElement | undefined
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `gridElement` | <code>HTMLElement</code> |  |

***

### parseDetailElement()

FrameworkAdapter hook called by MasterDetailPlugin during attach(). Delegates
to createDetailRenderer (bridge installed by master-detail feature).

```ts
parseDetailElement(detailElement: Element): (row: TRow, rowIndex: number) => string | HTMLElement | undefined
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `detailElement` | <code>Element</code> |  |

***

### createResponsiveCardRenderer()

Creates a responsive card renderer function for ResponsivePlugin. Delegates
to the bridge installed by `@toolbox-web/grid-angular/features/responsive`.

```ts
createResponsiveCardRenderer(gridElement: HTMLElement): (row: TRow, rowIndex: number) => HTMLElement | undefined
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `gridElement` | <code>HTMLElement</code> |  |

***

### parseResponsiveCardElement()

FrameworkAdapter hook called by ResponsivePlugin during attach(). Delegates
to createResponsiveCardRenderer (bridge installed by responsive feature).

```ts
parseResponsiveCardElement(cardElement: Element): (row: TRow, rowIndex: number) => HTMLElement | undefined
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `cardElement` | <code>Element</code> |  |

***

### createToolPanelRenderer()

Creates a tool panel renderer from a light DOM element.
The renderer creates an Angular template-based panel content.

```ts
createToolPanelRenderer(element: HTMLElement): (container: HTMLElement) => void | () => void | undefined
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `element` | <code>HTMLElement</code> |  |

***

### getTypeDefault()

Gets type-level defaults from the application's GridTypeRegistry.

This enables application-wide type defaults configured via `provideGridTypeDefaults()`.
The returned TypeDefault contains renderer/editor functions that instantiate
Angular components dynamically.

```ts
getTypeDefault(type: string, _gridEl: HTMLElement): TypeDefault<TRow> | undefined
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `type` | <code>string</code> |  |
| `_gridEl` | <code>HTMLElement</code> |  |

***

### processGroupingColumnsConfig()

Processes a GroupingColumnsConfig. Delegates to the feature config
preprocessor installed by `@toolbox-web/grid-angular/features/grouping-columns`,
which handles converting Angular component class references to actual
renderer functions. Returns the input config unchanged if the feature
is not imported.

```ts
processGroupingColumnsConfig(config: TConfig): TConfig
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `config` | <code>TConfig</code> |  |

***

### processGroupingRowsConfig()

Processes a GroupingRowsConfig. Delegates to the feature config preprocessor
installed by `@toolbox-web/grid-angular/features/grouping-rows`.

```ts
processGroupingRowsConfig(config: TConfig): TConfig
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `config` | <code>TConfig</code> |  |

***

### processPinnedRowsConfig()

Processes a PinnedRowsConfig. Delegates to the feature config preprocessor
installed by `@toolbox-web/grid-angular/features/pinned-rows`.

```ts
processPinnedRowsConfig(config: TConfig): TConfig
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `config` | <code>TConfig</code> |  |

***

### releaseCell()

Called when a cell's content is about to be wiped (e.g., exiting edit mode,
scroll-recycling a row, or rebuilding a row).

Destroys any editor embedded views or component refs whose DOM is
inside the given cell element. This prevents memory leaks from
orphaned Angular views that would otherwise stay in the change
detection tree indefinitely.

```ts
releaseCell(cellEl: HTMLElement): void
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `cellEl` | <code>HTMLElement</code> |  |

***

### beginBatch()

Open a teardown batch. No-op for the Angular adapter — `viewRef.destroy()`
and `componentRef.destroy()` are synchronous DOM operations with no
deferred-commit warning analogous to React's `flushSync`. Implemented
for FrameworkAdapter parity so grid core's bulk-teardown
wrappers work uniformly across adapters.

```ts
beginBatch(_gridEl: HTMLElement): void
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `_gridEl` | <code>HTMLElement</code> |  |

***

### endBatch()

Close a teardown batch opened by beginBatch. No-op for Angular —
see beginBatch.

```ts
endBatch(_gridEl: HTMLElement): void
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `_gridEl` | <code>HTMLElement</code> |  |

***

### unmount()

Unmount a specific container (e.g., detail panel, tool panel).
Finds the matching view or component ref whose DOM nodes are inside
the container and properly destroys it to prevent memory leaks.

```ts
unmount(container: HTMLElement): void
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `container` | <code>HTMLElement</code> |  |

***

### destroy()

Clean up all view references and component references.
Call this when your app/component is destroyed.

```ts
destroy(): void
```

***
