@andmarruda/intelligent-grid-angular
v0.1.0
Published
Angular standalone component for Intelligent Grid, the Excel-like data grid powered by SorlaDB.
Maintainers
Readme
@andmarruda/intelligent-grid-angular
Angular standalone component for Intelligent Grid, the Excel-like data grid powered by SorlaDB. Angular 20+, works with or without zone.js.
npm install @andmarruda/intelligent-grid-angular @andmarruda/intelligent-grid sorla-dbAdd the stylesheet to angular.json ("styles": ["node_modules/@andmarruda/intelligent-grid/dist/intelligent-grid.css"]) or @import '@andmarruda/intelligent-grid/styles.css'; in your global styles.
import { Component, signal, viewChild } from '@angular/core';
import { IntelligentGridComponent } from '@andmarruda/intelligent-grid-angular';
import type { GridEvent } from '@andmarruda/intelligent-grid';
import sorla from 'sorla-db';
@Component({
selector: 'app-orders',
imports: [IntelligentGridComponent],
template: `
<button (click)="table()?.grid?.undo()">Undo</button>
<intelligent-grid [columns]="columns" [data]="rows()" [options]="options"
(cellChange)="save($event)" />
`
})
export class OrdersComponent {
readonly table = viewChild(IntelligentGridComponent);
readonly rows = signal<Record<string, unknown>[]>([]);
readonly columns = [
{ field: 'product', title: 'Product' },
{ field: 'qty', type: 'integer' as const },
{ field: 'price', type: 'currency' as const },
{ field: 'total', type: 'currency' as const, formula: '=[@qty]*[@price]' }
];
readonly options = { sorla, idField: 'id', editable: true, height: 480 };
save(event: GridEvent) { /* event.detail: { id, field, value, oldValue, row } */ }
}| Input / output | |
| --- | --- |
| [columns] | Column definitions. A new array calls grid.setColumns(). |
| [data] | Rows. A new array calls grid.setData() (resets edits, undo and selection). |
| [options] | Every other grid option. Read once, when the grid is created. |
| (gridEvent) | Every grid event (check event.type). |
| (ready), (cellChange), (rowChange), (rowClick), (rowDblClick), (selectionChange), (dataChange), (changes) | The most used events, as their own outputs. |
| grid | The IntelligentGrid instance, through viewChild or a template reference. |
See the grid documentation for options, events and the API.
