Getting started with Angular Kanban component
11 Jul 20249 minutes to read
This section explains the steps required to create a simple Angular Kanban component and configure its available functionalities.
Setup Angular Environment
Use Angular CLI
to setup the Angular applications. To install Angular CLI, use the following command.
npm install -g @angular/cli
Create an Angular Application
Start a new Angular application using the following Angular CLI command.
ng new my-app
cd my-app
Installing Syncfusion Kanban package
Syncfusion packages are distributed in npm as @syncfusion
scoped packages. Get all the Angular Syncfusion package from npm link.
Currently, Syncfusion provides two types of package structures for Angular components. They are:
- Ivy library distribution package format
- Angular compatibility compiler(Angular’s legacy compilation and rendering pipeline) package.
Ivy library distribution package
Syncfusion Angular packages(>=20.2.36
) has been moved to the Ivy distribution to support the Angular Ivy rendering engine and the package are compatible with Angular version 12 and above. To download the package use the following command.
Add @syncfusion/ej2-angular-kanban
package to the application.
npm install @syncfusion/ej2-angular-kanban --save
Angular compatibility compiled package(ngcc)
For Angular version below 12, use the legacy (ngcc) package of the Syncfusion Angular components. To download the ngcc
package, use the following command.
Add @syncfusion/ej2-angular-kanban@ngcc
package to the application.
npm install @syncfusion/ej2-angular-kanban@ngcc --save
To mention the ngcc package in the package.json
file, add the suffix -ngcc
with the package version as follows.
@syncfusion/ej2-angular-kanbanr:"20.2.38-ngcc"
Note: If the ngcc tag is not specified while installing the package, the Ivy Library Package will be installed and this package will throw a warning.
Adding CSS reference
Add Kanban component’s styles as given in the following styles.css.
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/material.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css';
@import '../node_modules/@syncfusion/ej2-layouts/styles/material.css';
@import '../node_modules/@syncfusion/ej2-navigations/styles/material.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
@import '../node_modules/@syncfusion/ej2-angular-kanban/styles/material.css';
Add Kanban component
Modify the template in the [src/app/app.component.ts] file to render the Kanban component. Add the Angular Kanban by using the <ejs-kanban>
selector in the template
section of the app.component.ts file.
src/app/app.component.ts
import { KanbanModule } from '@syncfusion/ej2-angular-kanban'
import { Component } from '@angular/core';
@Component({
imports: [
KanbanModule
],
standalone: true,
selector: 'app-root',
// specifies the template string for the Kanban component
template: `<ejs-kanban>
<e-columns>
<e-column headerText='To do' keyField='Open'></e-column>
<e-column headerText='In Progress' keyField='InProgress'></e-column>
<e-column headerText='Testing' keyField='Testing'></e-column>
<e-column headerText='Done' keyField='Close'></e-column>
</e-columns>
</ejs-kanban>`
})
export class AppComponent { }
Run the application
Use the following command to run the application in the browser.
ng serve --open
The output will appear as follows.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { KanbanModule } from '@syncfusion/ej2-angular-kanban'
import { Component } from '@angular/core';
@Component({
imports: [
KanbanModule
],
standalone: true,
selector: 'app-root',
template: `<ejs-kanban>
<e-columns>
<e-column headerText='To do' keyField='Open'></e-column>
<e-column headerText='In Progress' keyField='InProgress'></e-column>
<e-column headerText='Testing' keyField='Testing'></e-column>
<e-column headerText='Done' keyField='Close'></e-column>
</e-columns>
</ejs-kanban>`
})
export class AppComponent { }
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Populating cards
To populate the empty Kanban with cards, define the local JSON data or remote data using the dataSource
property. To define dataSource
, the mandatory fields in JSON object should be relevant to keyField
. In the following example, you can see the cards defined with default fields such as ID, Summary, and Status.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { KanbanModule } from '@syncfusion/ej2-angular-kanban'
import { Component } from '@angular/core';
import { CardSettingsModel } from '@syncfusion/ej2-angular-kanban';
import { kanbanData } from './datasource';
@Component({
imports: [
KanbanModule
],
standalone: true,
selector: 'app-root',
template: `<ejs-kanban keyField='Status' [dataSource]='data' [cardSettings]='cardSettings'>
<e-columns>
<e-column headerText='To do' keyField='Open'></e-column>
<e-column headerText='In Progress' keyField='InProgress'></e-column>
<e-column headerText='Testing' keyField='Testing'></e-column>
<e-column headerText='Done' keyField='Close'></e-column>
</e-columns>
</ejs-kanban>`
})
export class AppComponent {
public data: Object[] = kanbanData;
public cardSettings: CardSettingsModel = {
contentField: 'Summary',
headerField: 'Id'
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Enable swimlane
Swimlane
can be enabled by mapping the fields swimlaneSettings.keyField
to appropriate column name in dataSource. This enables the grouping of the cards based on the mapped column values.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { KanbanModule } from '@syncfusion/ej2-angular-kanban'
import { Component } from '@angular/core';
import { CardSettingsModel, SwimlaneSettingsModel } from '@syncfusion/ej2-angular-kanban';
import { kanbanData } from './datasource';
@Component({
imports: [
KanbanModule
],
standalone: true,
selector: 'app-root',
template: `<ejs-kanban keyField='Status' [dataSource]='data' [cardSettings]='cardSettings' [swimlaneSettings]='swimlaneSettings'>
<e-columns>
<e-column headerText='To do' keyField='Open'></e-column>
<e-column headerText='In Progress' keyField='InProgress'></e-column>
<e-column headerText='Testing' keyField='Testing'></e-column>
<e-column headerText='Done' keyField='Close'></e-column>
</e-columns>
</ejs-kanban>`
})
export class AppComponent {
public data: Object[] = kanbanData;
public cardSettings: CardSettingsModel = {
contentField: 'Summary',
headerField: 'Id'
};
public swimlaneSettings: SwimlaneSettingsModel = { keyField: 'Assignee' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));