@gridcraft/angular
v1.0.0
Published
A data grid for Angular. Standalone components, signals throughout, and it runs with or without Zone.js. Its only runtime dependency is `tslib`.
Readme
@gridcraft/angular
A data grid for Angular. Standalone components, signals throughout, and it runs with or
without Zone.js. Its only runtime dependency is tslib.
Documentation and live examples: https://gridcraft.anonovix.com/docs
Install
npm install @gridcraft/angularThe peer range is @angular/core and @angular/common >=19.0.0 <23.0.0. One release covers all
four majors, and npm refuses the install outside that range instead of letting the build fail later.
Add a theme
The grid is unstyled until a theme is loaded. Add one line to your global styles.scss:
@use '@gridcraft/angular/themes/default';dark and material are also included. Load one theme per app. Each is scoped to the class the
grid puts on its own root element, so nothing leaks into the rest of your styles.
If you don't use SCSS, add node_modules/@gridcraft/angular/themes/default.scss to the styles
array in angular.json instead.
A first grid
import { Component } from '@angular/core';
import { of } from 'rxjs';
import { GridcraftComponent, type FetchParams, type GridColumn, type GridConfig } from '@gridcraft/angular';
interface Person { id: number; name: string; role: string; salary: number; }
const PEOPLE: Person[] = [
{ id: 1, name: 'Alice Chen', role: 'Engineer', salary: 95000 },
{ id: 2, name: 'Bob Martin', role: 'Designer', salary: 82000 },
{ id: 3, name: 'David Kim', role: 'Manager', salary: 115000 },
];
@Component({
selector: 'app-people',
imports: [GridcraftComponent],
template: `<gridcraft [columns]="columns" [dataSource]="dataSource" [config]="config" />`,
})
export class PeopleComponent {
columns: GridColumn<Person>[] = [
{ key: 'name', name: 'Name', prop: 'name', sizing: 'flex', sortable: true, filter: { type: 'text' } },
{ key: 'role', name: 'Role', prop: 'role', width: 130, sortable: true, filter: { type: 'text' } },
{ key: 'salary', name: 'Salary', prop: 'salary', width: 120, sortable: true, filter: { type: 'number' } },
];
dataSource = {
fetchRows: (p: FetchParams) => of({
rows: PEOPLE.slice(p.offset, p.offset + p.limit),
totalCount: PEOPLE.length,
}),
};
config: GridConfig<Person> = {
height: 380, // the grid needs a height to have a scroll viewport
sortMode: 'client', // sort the loaded rows in memory
filterMode: 'row', // a filter input under each header
filterApplyMode: 'client', // filter the loaded rows in memory
};
}Three inputs carry everything:
columnssays what to show.dataSourcesupplies rows. Its whole contract is one method,fetchRows(params), returning anObservable<{ rows, totalCount }>. For an in-memory array, wrap it inof()as above. For a server, call your API there instead: the grid passes the offset, page size, sorts and filters inparams.configholds everything else. Every key is optional, but set aheight: without one the grid has no scroll viewport.
There is no module to register. GridcraftComponent is standalone, and so is everything else in the
package.
What the package covers
- Data: in-memory or server-side, with paging, infinite scroll and row virtualisation for large
sets. Live row updates through
applyTransaction(). - Columns: resize, reorder, pin, auto-size, column groups, value getters and formatters, cell templates and renderers, tooltips, conditional formatting, cell spanning.
- Rows: sorting, single and multi selection with checkboxes, expandable rows with your own template, pinned rows, row dragging, auto row height, full-width rows.
- Filtering: text, number and date filters in a filter row or popup, a quick filter across every column, external filters, and filter state you can save and restore.
- Editing: inline cell and row editing, validation, batch edits across selected rows, and undo/redo.
- Output: CSV export and a print/PDF layout.
- Everything else: theming through CSS custom properties, RTL, localisation, keyboard navigation, screen-reader support, and server-side rendering.
Each of these has its own page with a working example in the documentation.
App-wide defaults
To stop repeating the same options on every grid, set them once in your root providers. A grid's
own [config] still wins over anything set here.
import { provideGridDefaults } from '@gridcraft/angular/core';
export const appConfig: ApplicationConfig = {
providers: [
provideGridDefaults({ rowHeight: 48, pageSize: 50, columnResize: true, columnReorder: true }),
],
};Where to go next
- Quick start: the example above, built up one feature at a time.
- Server data and infinite scroll: the same grid over HTTP.
- Filtering: every filter type and how filters reach your API.
- Theming: restyling with CSS custom properties, and a visual theme builder.
- Angular compatibility: which versions are supported and why 19 is the floor.
Licence
MIT. The full text ships with the package in LICENSE.md.
