Kanban - HTML UI Elements for Mobile & Web Applications | www.HtmlElements.com

Overview

Smart.Kanban represents a kanban board that visually depicts work at various stages of a process using cards to represent tasks and columns to represent each stage of the process.

Getting Started with Kanban Web Component

Smart UI for Web Components is distributed as smart-webcomponents NPM package. You can also get the full download from our website with all demos from the Download page.

Setup the Kanban

Smart UI for Web Components is distributed as smart-webcomponents NPM package

  1. Download and install the package.

    npm install smart-webcomponents

  2. Once installed, import the Kanban module in your application.

    <script type="module" src="node_modules/smart-webcomponents/source/modules/smart.kanban.js"></script>

  3. Adding CSS reference

    The smart.default.css CSS file should be referenced using following code.

    <link rel="stylesheet" type="text/css" href="node_modules/smart-webcomponents/source/styles/smart.default.css" />

  4. Add the Kanban tag to your Web Page

    <smart-kanban id="kanban"></smart-kanban>

  5. Create the Kanban Component

    	<script type="module">
    		Smart('#kanban', class {
    			get properties() {
    				return {
    			    collapsible: true,
    				dataSource: window.getKanbanData(),
    				columns: [
    					{ label: 'To do', dataField: 'toDo' },
    					{ label: 'In progress', dataField: 'inProgress' },
    					{ label: 'Testing', dataField: 'testing' },
    					{ label: 'Done', dataField: 'done' }
    				]
    			}
    			}
    		});
    	</script>	   
    		

    Another option is to create the Kanban is by using the traditional Javascript way:
    	const kanban = document.createElement('smart-kanban');
    
    	kanban.disabled = true;
    	document.body.appendChild(kanban);
    		

    Smart framework provides a way to dynamically create a web component on demand from a DIV tag which is used as a host. The following imports the web component's module and creates it on demand, when the document is ready. The #kanban is the ID of a DIV tag.

    	import "../../source/modules/smart.kanban.js";
    
    	document.readyState === 'complete' ? init() : window.onload = init;
    
    	function init() { 
    		const kanban = new Smart.Kanban('#kanban', {
    			    collapsible: true,
    				dataSource: window.getKanbanData(),
    				columns: [
    					{ label: 'To do', dataField: 'toDo' },
    					{ label: 'In progress', dataField: 'inProgress' },
    					{ label: 'Testing', dataField: 'testing' },
    					{ label: 'Done', dataField: 'done' }
    				]
    			});
    	}
    	

  6. Open the page in your web server.

Tasks

In Smart.Kanban data loaded from the data source is visualized via task cards displayed in columns. Tasks have various properties reflected in the cards. Details abount these are listed below.

  1. Text - corresponds to the data source text field.
  2. Completed sub-tasks - corresponds to the data source checklist field. Visiblity contolled by property taskProgress and whether sub-tasks are defined.
  3. Progress - corresponds to the data source progress field. Visiblity contolled by property taskProgress.
  4. User icon - corresponds to the data source userId field. Visiblity contolled by property taskUserIcon.
  5. Comments icon - opens the Comments list with comments corresponding to the data source comments field. Visiblity contolled by property taskComments.
  6. Actions icon - opens the Actions list (Edit/Copy/Remove). Visiblity contolled by property taskActions.
  7. Tags - corresponds to the data source tags field. Visiblity contolled by property taskTags.
  8. Due date - corresponds to the data source dueDate field. Visiblity contolled by property taskDue.
  9. Priority icon - by default, shown only for low and high priority. Corresponds to the data source priority field. Visiblity contolled by property taskPriority.
  10. Color band - corresponds to the data source color field. If color is not set, the theme's primary color is applied.

Task Drag/Drop

Smart.Kanban allows the dragging and dropping of tasks if the properties allowDrag and allowDrop are enabled (which, by default, they are).

Multiple tasks can be dragged simultaneously by selecting them first (in selectionMode: 'zeroOrManyExtended').

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Kanban Basic Demo</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="../../../source/styles/smart.default.css" />
    <link rel="stylesheet" type="text/css" href="../../../styles/demos.css" />
    <link rel="stylesheet" type="text/css" href="styles.css" />
    <script type="text/javascript" src="../../../scripts/data.js"></script>
    <script type="text/javascript" src="../../../source/smart.element.js"></script>
    <script type="text/javascript" src="../../../source/smart.button.js"></script>
    <script type="text/javascript" src="../../../source/smart.calendar.js"></script>
    <script type="text/javascript" src="../../../source/smart.complex.js"></script>
    <script type="text/javascript" src="../../../source/smart.data.js"></script>
    <script type="text/javascript" src="../../../source/smart.date.js"></script>
    <script type="text/javascript" src="../../../source/smart.datetimepicker.js"></script>
    <script type="text/javascript" src="../../../source/smart.draw.js"></script>
    <script type="text/javascript" src="../../../source/smart.dropdownlist.js"></script>
    <script type="text/javascript" src="../../../source/smart.combobox.js"></script>
    <script type="text/javascript" src="../../../source/smart.export.js"></script>
    <script type="text/javascript" src="../../../source/smart.filter.js"></script>
    <script type="text/javascript" src="../../../source/smart.input.js"></script>
    <script type="text/javascript" src="../../../source/smart.colorinput.js"></script>
    <script type="text/javascript" src="../../../source/smart.listbox.js"></script>
    <script type="text/javascript" src="../../../source/smart.math.js"></script>
    <script type="text/javascript" src="../../../source/smart.numeric.js"></script>
    <script type="text/javascript" src="../../../source/smart.numerictextbox.js"></script>
    <script type="text/javascript" src="../../../source/smart.scrollbar.js"></script>
    <script type="text/javascript" src="../../../source/smart.sortable.js"></script>
    <script type="text/javascript" src="../../../source/smart.timepicker.js"></script>
    <script type="text/javascript" src="../../../source/smart.tooltip.js"></script>
    <script type="text/javascript" src="../../../source/smart.window.js"></script>
    <script type="text/javascript" src="../../../source/smart.gridpanel.js"></script>
    <script type="text/javascript" src="../../../source/smart.kanban.js"></script>
    <script type="text/javascript">
        Smart('#kanban', class {
            get properties() {
                return {
                    allowDrag: true,
                    allowDrop: true,
                    collapsible: true,
                    dataSource: getKanbanData(),
                    selectionMode: 'zeroOrManyExtended',
                    columns: [
                        { label: 'To do', dataField: 'toDo' },
                        { label: 'In progress', dataField: 'inProgress' },
                        { label: 'Testing', dataField: 'testing' },
                        { label: 'Done', dataField: 'done' }
                    ]
                };
            }
        });
    </script>
</head>
<body>
    <smart-kanban id="kanban"></smart-kanban>
</body>
</html>

Demo

kanban

Dragging between multiple Kanbans is also supported:

kanban cards dragging

Column Collapsing

The columns of Smart.Kanban can be collapsed to make more space or highlight other columns. However, one column always remains expanded. Collapsing can be disabled by setting collapsible to true. To disable collapsing for particular columns only, set collapsible to false in their column definitions.

kanban column collapsing

Column Orientation

Tasks in columns can either be vertically (default) or horizontally ordered. The orientation property can be applied in the column definition.

columns: [
    { label: 'To do', dataField: 'toDo', orientation: 'horizontal' },
    { label: 'In progress', dataField: 'inProgress', orientation: 'vertical' },
    { label: 'Done', dataField: 'done', orientation: 'horizontal' }
]
kanban column orientation

Resizing

Smart.Kanban is built upon the CSS Grid Layout technology which allows the component to seemlessly resize with minimum JavaScript calculations. This makes Kanban particularly useful when viewed on mobile devices.

kanban resize

Advanced Features

Details about the Kanban's advanced features is given in the following topics:

Methods

Smart.Kanban has the following methods:

  • addFilter(filters, operator) - adds filtering.
  • addSort(dataFields, orderBy) - adds sorting.
  • addTask(data) - Adds a task to a Kanban column.
  • beginEdit(task) - begins an edit operation.
  • cancelEdit() - ends the current edit operation and discards changes.
  • closePanel() - closes any open header panel (drop down).
  • collapse(column) - collapses a Kanban column.
  • copyTask(task) - creates a copy of a task in the same column.
  • endEdit() - ends the current edit operation and saves changes.
  • ensureVisible(task) - makes sure a task is visible by scrolling to it.
  • expand(column) - expands a Kanban column.
  • expandAll() - expands all Kanban columns.
  • exportData(dataFormat, fileName, callback) - exports the Kanban's data.
  • getState(task) - gets the Kanban's state.
  • loadState(state) - loads the Kanban's state.
  • moveTask(task, newStatus) - moves a task to a different column.
  • openCustomizePanel() - opens the "Customize tasks" header panel (drop down).
  • openFilterPanel() - opens the "Filter" header panel (drop down).
  • openSortPanel() - opens the "Sort" header panel (drop down).
  • removeFilter() - removes filtering.
  • removeSort() - removes sorting.
  • removeTask(task, prompt) - removes a task.
  • saveState() - saves the Kanban's state to the browser's localStorage.
  • updateTask(task, newData) - updates a task.

Create, Append, Remove, Get/Set Property, Invoke Method, Bind to Event


Create a new element:
	const kanban = document.createElement('smart-kanban');
	

Append it to the DOM:
	document.body.appendChild(kanban);
	

Remove it from the DOM:
	kanban.parentNode.removeChild(kanban);
	

Set a property:
	kanban.propertyName = propertyValue;
	

Get a property value:
	const propertyValue = kanban.propertyName;
	

Invoke a method:
	kanban.methodName(argument1, argument2);
	

Add Event Listener:
	const eventHandler = (event) => {
	   // your code here.
	};

	kanban.addEventListener(eventName, eventHandler);
	

Remove Event Listener:
	kanban.removeEventListener(eventName, eventHandler, true);
	

Using with Typescript

Smart Web Components package includes TypeScript definitions which enables strongly-typed access to the Smart UI Components and their configuration.

Inside the download package, the typescript directory contains .d.ts file for each web component and a smart.elements.d.ts typescript definitions file for all web components. Copy the typescript definitions file to your project and in your TypeScript file add a reference to smart.elements.d.ts

Read more about using Smart UI with Typescript.

Getting Started with Angular Kanban Component

Setup Angular Environment

Angular provides the easiest way to set angular CLI projects using Angular CLI tool.

Install the CLI application globally to your machine.

npm install -g @angular/cli

Create a new Application

ng new smart-angular-kanban

Navigate to the created project folder

cd smart-angular-kanban

Setup the Kanban

Smart UI for Angular is distributed as smart-webcomponents-angular NPM package

  1. Download and install the package.
    npm install smart-webcomponents-angular
  2. Once installed, import the KanbanModule in your application root or feature module.

    app.module.ts

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    
    import { KanbanModule } from 'smart-webcomponents-angular/kanban';
    
    import { AppComponent } from './app.component';
    
    @NgModule({
        declarations: [ AppComponent ],
        imports: [ BrowserModule, KanbanModule ],
        bootstrap: [ AppComponent ]
    })
    
    export class AppModule { }
    	

  3. Adding CSS reference

    The following CSS file is available in ../node_modules/smart-webcomponents-angular/ package folder. This can be referenced in [src/styles.css] using following code.

    	@import 'smart-webcomponents-angular/source/styles/smart.default.css';

    Another way to achieve the same is to edit the angular.json file and in the styles add the style.

    	"styles": [
    		"node_modules/smart-webcomponents-angular/source/styles/smart.default.css"
    	]
    	
  4. Example


    app.component.html

     
    <smart-kanban #kanban id="kanban" [collapsible]="collapsible" [dataSource]="dataSource" [columns]="columns">
    </smart-kanban>
    		

    app.component.ts

     
    import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from '@angular/core';
    import { KanbanComponent } from 'smart-webcomponents-angular/kanban';
    import { GetKanbanData } from '../../common/data';
    
    
    @Component({
        selector: 'app-root',
        templateUrl: './app.component.html',
        styleUrls: ['./app.component.css'],
        encapsulation: ViewEncapsulation.None
    })
    
    export class AppComponent implements AfterViewInit, OnInit {
        @ViewChild('kanban', { read: KanbanComponent, static: false }) kanban!: KanbanComponent;
    
        collapsible = true;
        dataSource = GetKanbanData();
        columns = [
            { label: 'To do', dataField: 'toDo' },
            { label: 'In progress', dataField: 'inProgress' },
            { label: 'Testing', dataField: 'testing' },
            { label: 'Done', dataField: 'done' }
        ];
    
        ngOnInit(): void {
            // onInit code.
        }
    
        ngAfterViewInit(): void {
            // afterViewInit code.
            this.init();
        }
    
        init(): void {
            // init code.
    
    
    
        }
    }
    		

    app.module.ts

     
    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    
    import { KanbanModule } from 'smart-webcomponents-angular/kanban';
    
    import { AppComponent } from './app.component';
    
    @NgModule({
        declarations: [ AppComponent ],
        imports: [ BrowserModule, KanbanModule ],
        bootstrap: [ AppComponent ]
    })
    
    export class AppModule { }
    		


Running the Angular application

After completing the steps required to render a Kanban, run the following command to display the output in your web browser

ng serve
and open localhost:4200 in your favorite web browser.

Read more about using Smart UI for Angular: https://www.htmlelements.com/docs/angular-cli/.

Getting Started with React Kanban Component

Setup React Environment

The easiest way to start with React is to use create-react-app. To scaffold your project structure, follow the installation instructions.

npx create-react-app my-app
cd my-app
npm start	
	

Preparation

Open src/App.js andsrc/App.css

  1. Remove everything inside the App div tag in src/App.js:
    <div className="App"> </div>
  2. Remove the logo.svg import
  3. Remove the contents of src/App.css
  4. Remove src/logo.svg

Setup the Kanban

Smart UI for React is distributed as smart-webcomponents-react NPM package

  1. Download and install the package.
    npm install smart-webcomponents-react
  2. Once installed, import the React Kanban Component and CSS files in your application and render it app.js

    import 'smart-webcomponents-react/source/styles/smart.default.css';
    import React from "react";
    import ReactDOM from 'react-dom/client';
    import { Kanban } from 'smart-webcomponents-react/kanban';
    import { GetKanbanData } from './common/data';
    
    function App() {
    	const dataSource = GetKanbanData();
    	const columns = [{
    		label: 'To do',
    		dataField: 'toDo'
    	},
    	{
    		label: 'In progress',
    		dataField: 'inProgress'
    	},
    	{
    		label: 'Testing',
    		dataField: 'testing'
    	},
    	{
    		label: 'Done',
    		dataField: 'done'
    	}
    	]
    
    	return (
    		<div>
    			<Kanban
    				columns={columns}
    				dataSource={dataSource}
    				collapsible>
    			</Kanban>
    		</div>
    	);
    }
    
    
    
    export default App;
    	

Running the React application

Start the app with
npm start
and open localhost:3000 in your favorite web browser to see the output.

Read more about using Smart UI for React: https://www.htmlelements.com/docs/react/.

Getting Started with Vue Kanban Component


Setup Vue Environment

We will use vue-cli to get started. Let's install vue-cli

npm install -g @vue/cli

Then we can start creating our Vue.js projects with:

vue create my-project

Setup the Kanban

Open the "my-project" folder and run:

npm install smart-webcomponents

Setup with Vue 3.x

  • Make Vue ignore custom elements defined outside of Vue (e.g., using the Web Components APIs). Otherwise, it will throw a warning about an Unknown custom element, assuming that you forgot to register a global component or misspelled a component name.

    Open src/main.js in your favorite text editor and change its contents to the following:

    main.js

    import { createApp } from 'vue'
    import App from './App.vue'
    
    const app = createApp(App)
    
    app.config.isCustomElement = tag => tag.startsWith('smart-');
    app.mount('#app')
    		
  • Open src/App.vue in your favorite text editor and change its contents to the following:

    App.vue

    <template>
      <div class="vue-root">
        <smart-kanban id="kanban"></smart-kanban>
      </div>
    </template>
    
    <script>
    import { onMounted } from "vue";
    import "smart-webcomponents/source/styles/smart.default.css";
    import "smart-webcomponents/source/modules/smart.kanban.js";
    
    window.getKanbanData = function getKanbanData(locale = 'en') {
        const text = {
            en: [
                'Research', 'Displaying data from data source', 'Showing cover and title', 'Property validation',
                'formatFunction and formatSettings', 'Expand/collapse arrow', 'Virtual scrolling', 'Deferred scrolling',
                'Infinite scrolling', 'Visible/hidden columns', 'Public methods', 'Editing',
                'Header', 'Dragging with feedback', 'Vertical virtualization', 'Observable columns array',
                'Reusing existing HTML elements', 'Virtualize collapsed cards'
            ],
            he: [
                'מחקר', 'הצגת נתונים ממקור נתונים', 'מראה כריכה וכותרת', 'אימות נכס',
                'formatFunction ו formatSettings', 'הרחב / כווץ חץ', 'גלילה וירטואלית', 'גלילה נדחית',
                'גלילה אינסופית', 'עמודות גלויות / מוסתרות', 'שיטות ציבוריות', 'עריכה',
                'כותרת עליונה', 'גרירה עם משוב', 'וירטואליזציה אנכית', 'מערך עמודות ניתן לצפייה',
                'שימוש חוזר באלמנטים HTML קיימים', 'וירטואליזציה של כרטיסים שהתמוטטו'
            ]
        },
            tags = {
                en: ['initial', 'data', 'visual', 'property', 'scrolling', 'method'],
                he: ['התחלתי', 'נתונים', 'חזותי', 'תכונה', 'גלילה', 'שיטה']
            },
            data = [
                {
                    id: 0,
                    status: 'done',
                    text: text[locale][0],
                    tags: tags[locale][0],
                    progress: 100,
                    userId: 2
    
                }, {
                    id: 1,
                    status: 'done',
                    text: text[locale][1],
                    tags: tags[locale][1],
                    priority: 'high',
                    progress: 100,
                    userId: 3
                }, {
                    id: 2,
                    status: 'done',
                    text: text[locale][2],
                    tags: tags[locale][2] + ', ' + tags[locale][3],
                    priority: 'high',
                    progress: 100,
                    userId: 2
                }, {
                    id: 3,
                    status: 'done',
                    text: text[locale][3],
                    tags: tags[locale][3],
                    checklist: [
                        { text: 'addNewButton', completed: true },
                        { text: 'allowDrag', completed: true },
                        { text: 'cardHeight', completed: true },
                        { text: 'cellOrientation', completed: true },
                        { text: 'collapsible', completed: true },
                        { text: 'columns', completed: true }
                    ],
                    userId: 1
                }, {
                    id: 4,
                    status: 'done',
                    text: text[locale][4],
                    tags: tags[locale][1] + ', ' + tags[locale][3],
                    progress: 100,
                    userId: 0
                }, {
                    id: 5,
                    status: 'testing',
                    text: text[locale][5],
                    tags: tags[locale][2],
                    progress: 90,
                    userId: 3
                }, {
                    id: 7,
                    status: 'testing',
                    text: text[locale][6],
                    tags: tags[locale][4] + ', ' + tags[locale][1],
                    progress: 10,
                    userId: 3
                }, {
                    id: 6,
                    status: 'testing',
                    text: text[locale][7],
                    tags: tags[locale][4],
                    color: '#9966CC',
                    userId: 3
                }, {
                    id: 8,
                    status: 'inProgress',
                    text: text[locale][8],
                    tags: tags[locale][4] + ', ' + tags[locale][1],
                    progress: 25,
                    userId: 0
                }, {
                    id: 9,
                    status: 'inProgress',
                    text: text[locale][9],
                    tags: tags[locale][2],
                    priority: 'high',
                    progress: 85,
                    color: 'red',
                    userId: 1
                }, {
                    id: 10,
                    status: 'inProgress',
                    text: text[locale][10],
                    tags: tags[locale][5],
                    checklist: [
                        { text: 'closePanel', completed: true },
                        { text: 'openCustomizePanel', completed: true },
                        { text: 'openFilterPanel', completed: true },
                        { text: 'openSortPanel', completed: false },
                        { text: 'showColumn', completed: false },
                        { text: 'hideColumn', completed: false },
                        { text: 'addFilter', completed: false },
                        { text: 'removeFilter', completed: false }
                    ],
                    userId: 2
                }, {
                    id: 11,
                    status: 'toDo',
                    text: text[locale][11],
                    tags: tags[locale][5],
                    priority: 'high',
                    progress: 0
                }, {
                    id: 12,
                    status: 'toDo',
                    text: text[locale][12],
                    tags: tags[locale][2]
                }, {
                    id: 13,
                    status: 'toDo',
                    text: text[locale][13],
                    tags: tags[locale][2] + ', ' + tags[locale][5] + ', ' + tags[locale][1],
                    priority: 'low',
                    userId: 4
                }, {
                    id: 14,
                    status: 'toDo',
                    text: text[locale][14],
                    checklist: [
                        { text: text[locale][16], completed: false },
                        { text: text[locale][17], completed: false }
                    ],
                    userId: 1
                }, {
                    id: 15,
                    status: 'toDo',
                    text: text[locale][15],
                    tags: tags[locale][1]
                }
            ],
            time = new Date().getTime(),
            msInMonth = 2592000000,
            msInDay = 86400000,
            comments = [
                'Ut ultrices dolor vitae magna lacinia vehicula.',
                'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
                'Donec vitae dapibus mauris, quis cursus nibh.',
                'Aenean ultrices maximus ex id scelerisque. Suspendisse cursus maximus nulla, sed ornare lectus aliquet eu. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.',
                'Curabitur at accumsan metus, rhoncus porttitor ligula.',
                'Nulla sodales faucibus accumsan.'
            ];
    
        for (let i = 0; i < data.length; i++) {
            const task = data[i];
    
            if (task.status === 'inProgress') {
                task.startDate = new Date(time - Math.floor(Math.random() * 9 + 1) * msInDay);
            }
            else if (task.status === 'testing') {
                task.startDate = new Date(time - Math.floor(Math.random() * 20 + 10) * msInDay);
            }
            else if (task.status === 'done') {
                task.startDate = new Date(time - Math.floor(Math.random() * 20 + 20) * msInDay);
            }
    
            if (task.priority === 'high' && task.status !== 'done') {
                task.dueDate = new Date(time - Math.floor(Math.random() * 3 + 1) * msInDay);
            }
            else if (task.priority === 'low') {
                task.dueDate = new Date(time + msInMonth + Math.floor(Math.random() * 30 + 10) * msInDay);
            }
            else if (task.startDate) {
                task.dueDate = new Date(task.startDate.getTime() + msInMonth + Math.floor(Math.random() * 2 + 1) * msInDay);
            }
            else {
                task.dueDate = new Date(time + msInMonth + Math.floor(Math.random() * 2 + 1) * msInDay);
            }
    
            let numberOfComments = Math.round(Math.random() * 3);
    
            task.comments = [];
    
            if (Math.round(Math.random() + 1) === 2) {
                let prevTime = time - Math.floor(Math.random() * 10 + 3) * msInDay;
    
                for (let j = 0; j < numberOfComments; j++) {
                    prevTime = prevTime + Math.floor(Math.random() * 2 + 1) * msInDay + msInDay / Math.floor(Math.random() * 5 + 1);
    
                    task.comments.push({
                        text: comments[Math.round(Math.random() * 5)],
                        userId: Math.round(Math.random() * 4),
                        time: new Date(prevTime)
                    });
                }
            }
        }
    
        return data;
    }	
    export default {
      name: "app",
      setup() {
        onMounted(() => {
          window.Smart(
            "#kanban",
            class {
              get properties() {
                return {
                  collapsible: true,
                  dataSource: window.getKanbanData(),
                  columns: [
                    {
                      label: "To do",
                      dataField: "toDo"
                    },
                    {
                      label: "In progress",
                      dataField: "inProgress"
                    },
                    {
                      label: "Testing",
                      dataField: "testing"
                    },
                    {
                      label: "Done",
                      dataField: "done"
                    }
                  ]
                };
              }
            }
          );
        });
      }
    };
    </script>
    
    <style>
    html,
    body,
    #kanban {
      width: 100%;
      height: 100%;
    }
    
    html,
    body {
      margin: 0;
    }
    </style>
    		
    We can now use the smart-kanban with Vue 3. Data binding and event handlers will just work right out of the box.

Setup with Vue 2.x

  • Make Vue ignore custom elements defined outside of Vue (e.g., using the Web Components APIs). Otherwise, it will throw a warning about an Unknown custom element, assuming that you forgot to register a global component or misspelled a component name.

    Open src/main.js in your favorite text editor and change its contents to the following:

    main.js

    import Vue from 'vue'
    import App from './App.vue'
    
    Vue.config.productionTip = false
    Vue.config.ignoredElements = [
    'smart-kanban'
    ]
    
    new Vue({
      render: h => h(App),
    }).$mount('#app')
  • Open src/App.vue in your favorite text editor and change its contents to the following:

    App.vue

    <template>  
    	  <smart-kanban id="kanban"></smart-kanban>  
    	 </template>   
    	 <script>  
    	 import "smart-webcomponents/source/styles/smart.default.css";  
    	 import 'smart-webcomponents/source/modules/smart.kanban.js';  
    	
    window.getKanbanData = function getKanbanData(locale = 'en') {
        const text = {
            en: [
                'Research', 'Displaying data from data source', 'Showing cover and title', 'Property validation',
                'formatFunction and formatSettings', 'Expand/collapse arrow', 'Virtual scrolling', 'Deferred scrolling',
                'Infinite scrolling', 'Visible/hidden columns', 'Public methods', 'Editing',
                'Header', 'Dragging with feedback', 'Vertical virtualization', 'Observable columns array',
                'Reusing existing HTML elements', 'Virtualize collapsed cards'
            ],
            he: [
                'מחקר', 'הצגת נתונים ממקור נתונים', 'מראה כריכה וכותרת', 'אימות נכס',
                'formatFunction ו formatSettings', 'הרחב / כווץ חץ', 'גלילה וירטואלית', 'גלילה נדחית',
                'גלילה אינסופית', 'עמודות גלויות / מוסתרות', 'שיטות ציבוריות', 'עריכה',
                'כותרת עליונה', 'גרירה עם משוב', 'וירטואליזציה אנכית', 'מערך עמודות ניתן לצפייה',
                'שימוש חוזר באלמנטים HTML קיימים', 'וירטואליזציה של כרטיסים שהתמוטטו'
            ]
        },
            tags = {
                en: ['initial', 'data', 'visual', 'property', 'scrolling', 'method'],
                he: ['התחלתי', 'נתונים', 'חזותי', 'תכונה', 'גלילה', 'שיטה']
            },
            data = [
                {
                    id: 0,
                    status: 'done',
                    text: text[locale][0],
                    tags: tags[locale][0],
                    progress: 100,
                    userId: 2
    
                }, {
                    id: 1,
                    status: 'done',
                    text: text[locale][1],
                    tags: tags[locale][1],
                    priority: 'high',
                    progress: 100,
                    userId: 3
                }, {
                    id: 2,
                    status: 'done',
                    text: text[locale][2],
                    tags: tags[locale][2] + ', ' + tags[locale][3],
                    priority: 'high',
                    progress: 100,
                    userId: 2
                }, {
                    id: 3,
                    status: 'done',
                    text: text[locale][3],
                    tags: tags[locale][3],
                    checklist: [
                        { text: 'addNewButton', completed: true },
                        { text: 'allowDrag', completed: true },
                        { text: 'cardHeight', completed: true },
                        { text: 'cellOrientation', completed: true },
                        { text: 'collapsible', completed: true },
                        { text: 'columns', completed: true }
                    ],
                    userId: 1
                }, {
                    id: 4,
                    status: 'done',
                    text: text[locale][4],
                    tags: tags[locale][1] + ', ' + tags[locale][3],
                    progress: 100,
                    userId: 0
                }, {
                    id: 5,
                    status: 'testing',
                    text: text[locale][5],
                    tags: tags[locale][2],
                    progress: 90,
                    userId: 3
                }, {
                    id: 7,
                    status: 'testing',
                    text: text[locale][6],
                    tags: tags[locale][4] + ', ' + tags[locale][1],
                    progress: 10,
                    userId: 3
                }, {
                    id: 6,
                    status: 'testing',
                    text: text[locale][7],
                    tags: tags[locale][4],
                    color: '#9966CC',
                    userId: 3
                }, {
                    id: 8,
                    status: 'inProgress',
                    text: text[locale][8],
                    tags: tags[locale][4] + ', ' + tags[locale][1],
                    progress: 25,
                    userId: 0
                }, {
                    id: 9,
                    status: 'inProgress',
                    text: text[locale][9],
                    tags: tags[locale][2],
                    priority: 'high',
                    progress: 85,
                    color: 'red',
                    userId: 1
                }, {
                    id: 10,
                    status: 'inProgress',
                    text: text[locale][10],
                    tags: tags[locale][5],
                    checklist: [
                        { text: 'closePanel', completed: true },
                        { text: 'openCustomizePanel', completed: true },
                        { text: 'openFilterPanel', completed: true },
                        { text: 'openSortPanel', completed: false },
                        { text: 'showColumn', completed: false },
                        { text: 'hideColumn', completed: false },
                        { text: 'addFilter', completed: false },
                        { text: 'removeFilter', completed: false }
                    ],
                    userId: 2
                }, {
                    id: 11,
                    status: 'toDo',
                    text: text[locale][11],
                    tags: tags[locale][5],
                    priority: 'high',
                    progress: 0
                }, {
                    id: 12,
                    status: 'toDo',
                    text: text[locale][12],
                    tags: tags[locale][2]
                }, {
                    id: 13,
                    status: 'toDo',
                    text: text[locale][13],
                    tags: tags[locale][2] + ', ' + tags[locale][5] + ', ' + tags[locale][1],
                    priority: 'low',
                    userId: 4
                }, {
                    id: 14,
                    status: 'toDo',
                    text: text[locale][14],
                    checklist: [
                        { text: text[locale][16], completed: false },
                        { text: text[locale][17], completed: false }
                    ],
                    userId: 1
                }, {
                    id: 15,
                    status: 'toDo',
                    text: text[locale][15],
                    tags: tags[locale][1]
                }
            ],
            time = new Date().getTime(),
            msInMonth = 2592000000,
            msInDay = 86400000,
            comments = [
                'Ut ultrices dolor vitae magna lacinia vehicula.',
                'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
                'Donec vitae dapibus mauris, quis cursus nibh.',
                'Aenean ultrices maximus ex id scelerisque. Suspendisse cursus maximus nulla, sed ornare lectus aliquet eu. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.',
                'Curabitur at accumsan metus, rhoncus porttitor ligula.',
                'Nulla sodales faucibus accumsan.'
            ];
    
        for (let i = 0; i < data.length; i++) {
            const task = data[i];
    
            if (task.status === 'inProgress') {
                task.startDate = new Date(time - Math.floor(Math.random() * 9 + 1) * msInDay);
            }
            else if (task.status === 'testing') {
                task.startDate = new Date(time - Math.floor(Math.random() * 20 + 10) * msInDay);
            }
            else if (task.status === 'done') {
                task.startDate = new Date(time - Math.floor(Math.random() * 20 + 20) * msInDay);
            }
    
            if (task.priority === 'high' && task.status !== 'done') {
                task.dueDate = new Date(time - Math.floor(Math.random() * 3 + 1) * msInDay);
            }
            else if (task.priority === 'low') {
                task.dueDate = new Date(time + msInMonth + Math.floor(Math.random() * 30 + 10) * msInDay);
            }
            else if (task.startDate) {
                task.dueDate = new Date(task.startDate.getTime() + msInMonth + Math.floor(Math.random() * 2 + 1) * msInDay);
            }
            else {
                task.dueDate = new Date(time + msInMonth + Math.floor(Math.random() * 2 + 1) * msInDay);
            }
    
            let numberOfComments = Math.round(Math.random() * 3);
    
            task.comments = [];
    
            if (Math.round(Math.random() + 1) === 2) {
                let prevTime = time - Math.floor(Math.random() * 10 + 3) * msInDay;
    
                for (let j = 0; j < numberOfComments; j++) {
                    prevTime = prevTime + Math.floor(Math.random() * 2 + 1) * msInDay + msInDay / Math.floor(Math.random() * 5 + 1);
    
                    task.comments.push({
                        text: comments[Math.round(Math.random() * 5)],
                        userId: Math.round(Math.random() * 4),
                        time: new Date(prevTime)
                    });
                }
            }
        }
    
        return data;
    }	
    	 export default {  
    	  name: "app",  
    	  mounted: function() {  
    	   window.Smart(  
    		"#kanban", class {  
    		 get properties() {  
    			return  {
    			    collapsible: true,
    				dataSource: window.getKanbanData(),
    				columns: [
    					{ label: 'To do', dataField: 'toDo' },
    					{ label: 'In progress', dataField: 'inProgress' },
    					{ label: 'Testing', dataField: 'testing' },
    					{ label: 'Done', dataField: 'done' }
    				]
    			} 
    		 }  
    		}  
    	   );  
    	  }  
    	 };  
    	 </script>  
    	 <style>  
    	  body {  
    	   min-height: 700px;  
    	  }  
    	 </style>  
    	
    We can now use the smart-kanban with Vue. Data binding and event handlers will just work right out of the box.
    We have bound the properties of the smart-kanban to values in our Vue component.

Running the Vue application

Start the app with
npm run serve
and open localhost:8080 in your favorite web browser to see the output below:

Read more about using Smart UI for Vue: https://www.htmlelements.com/docs/vue/.