# TbwEditor

> _Since v0.1.1_

Structural directive for cell editor rendering.

This provides a cleaner syntax for defining custom cell editors without
the nested `<tbw-grid-column-editor>` and `<ng-template>` boilerplate.

## Usage

```html
<!-- Instead of this verbose syntax: -->
<tbw-grid-column field="status">
  <tbw-grid-column-editor>
    <ng-template let-value let-onCommit="onCommit" let-onCancel="onCancel">
      <app-status-editor [value]="value" (commit)="onCommit($event)" (cancel)="onCancel()" />
    </ng-template>
  </tbw-grid-column-editor>
</tbw-grid-column>

<!-- Use this cleaner syntax (with auto-wiring - no explicit bindings needed!): -->
<tbw-grid-column field="status">
  <app-status-editor *tbwEditor="let value" [value]="value" />
</tbw-grid-column>
```

## Template Context

The structural directive provides the same context as `GridColumnEditor`:
- `$implicit` / `value`: The cell value
- `row`: The full row data object
- `column`: The column configuration
- `onCommit`: Callback function to commit the new value (optional - auto-wired if component emits `commit` event)
- `onCancel`: Callback function to cancel editing (optional - auto-wired if component emits `cancel` event)

## Import

```typescript
import { TbwEditor } from '@toolbox-web/grid-angular';

@Component({
  imports: [TbwEditor],
  // ...
})
```

#### Example

```html
<tbw-grid-column field="status" editable>
  <app-status-editor *tbwEditor="let value" [value]="value" />
</tbw-grid-column>
```

## Methods

### ngOnDestroy()

A callback method that performs custom clean-up, invoked immediately
before a directive, pipe, or service instance is destroyed.

```ts
ngOnDestroy(): void
```

***

### ngTemplateContextGuard()

Static type guard for template context.
Uses `any` defaults for ergonomic template usage.

```ts
ngTemplateContextGuard(dir: TbwEditor, ctx: unknown): ctx
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `dir` | <code><a href="/grid/angular/api/utilities/tbweditor/">TbwEditor</a></code> |  |
| `ctx` | <code>unknown</code> |  |

***
