@thkl/agrid 0.1.1 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,13 +12,14 @@ npm install @thkl/agrid @angular/cdk
12
12
  ## Usage
13
13
 
14
14
  ```ts
15
- import { Component } from '@angular/core';
15
+ import { Component, viewChild } from '@angular/core';
16
16
  import {
17
17
  AgridComponent,
18
18
  AgridControl,
19
19
  AgridDataSource,
20
20
  AgridProvider,
21
21
  ColDef,
22
+ RowUpdateEvent,
22
23
  } from '@thkl/agrid';
23
24
 
24
25
  interface Person {
@@ -37,6 +38,7 @@ const columns: ColDef<Person>[] = [
37
38
  template: '<agrid [provider]="provider" />',
38
39
  })
39
40
  export class PeopleComponent {
41
+ readonly grid = viewChild(AgridComponent);
40
42
  readonly provider = new AgridProvider<Person>({
41
43
  columns,
42
44
  datasource: new AgridDataSource([
@@ -44,8 +46,49 @@ export class PeopleComponent {
44
46
  { id: 2, name: 'Bob' },
45
47
  ]),
46
48
  control: new AgridControl(),
49
+ headerGroups: [{ id: 'employee', label: 'Employee' }],
50
+ showChangedCellIndicator: true,
51
+ enableRowMarking: true,
52
+ confirmRowDelete: true,
47
53
  });
48
54
  }
49
55
  ```
50
56
 
57
+ Set `group: 'employee'` on adjacent columns to render the `Employee` label above them. Dragging
58
+ that grouped header moves its current contiguous column segment as one block. Reordering, hiding,
59
+ or pinning may split one group ID into multiple headers. Segments containing locked columns cannot
60
+ be dragged.
61
+
62
+ `confirmRowDelete` protects grid delete actions with a localized in-row Yes/No confirmation.
63
+ Direct calls to `AgridDataSource.removeRow()` remain immediate.
64
+
65
+ `enableRowMarking` adds a checkbox to each control cell. Marked rows are included in keyboard,
66
+ cell-context, and row-context copy operations. Read `grid.markedRowIndices()` or call
67
+ `grid.clearMarkedRows()` when the host needs to inspect or reset the copy basket.
68
+
69
+ Marking is independent from row selection. Cell and range copy use the same copied columns for
70
+ every marked row, while Copy row uses every visible column. Duplicate rows are omitted, and marked
71
+ rows remain included when filters hide them.
72
+
73
+ ## Saving edited rows
74
+
75
+ Use `rowChanged` to send one request after the user edits one or more fields in a row:
76
+
77
+ ```html
78
+ <agrid [provider]="provider" (rowChanged)="saveRow($event)" />
79
+ ```
80
+
81
+ ```ts
82
+ saveRow(event: RowUpdateEvent<Person>): void {
83
+ this.http.patch(`/api/people/${event.row.id}`, event.row).subscribe(() => {
84
+ this.grid()?.clearChangedCells(event.originalIndex);
85
+ });
86
+ }
87
+ ```
88
+
89
+ The event fires with the latest complete row when inline navigation leaves that row, or when the
90
+ sidebar editor Save button is used. `cellEdit` and `recordEdit` remain available for every committed
91
+ field change. With `showChangedCellIndicator: true`, changed cells keep a corner marker until the
92
+ PATCH succeeds. Override `--agrid-color-cell-changed` to customize its color.
93
+
51
94
  Full documentation and demos: https://thkl.github.io/agrid/