Vue UI Components Documentation

Vue Kanban Component

The Kanban component for Vue can be used to implement the kanban method for a project.

Prerequisites

Refer to Vue Getting Started before you start with this help topic.

Configuration

After you have created your App.vue file, here is how you should structure it:

The Kanban component for Vue requires the following import:

import JqxKanban from "jqwidgets-scripts/jqwidgets-vue/vue_jqxkanban.vue";

Add the jqxKanban component to the components section of the the Vue class:

 components: {
JqxKanban
},

Template

The App.vue has a <template> structural tag where we determine the application structure. There we will also set the tags for the new components - <JqxKanban/>

<template>
<JqxKanban :width="400" :height="400"
:columns="kanbanColumns" :resources="staff"
:source="kanbanSource">
</JqxKanban>
</template>

Properties

The properties of the <JqxKanban/> component are defined in the data member of the Vue class. We should put them in the return object of the data function:

data: function () {
return {
staff: [
{ id: 0, name: 'No name', image: 'images/common.png', common: true },
{ id: 1, name: 'Andrew Fuller', image: 'images/andrew.png' },
{ id: 2, name: 'Janet Leverling', image: 'images/janet.png' },
{ id: 3, name: 'Steven Buchanan', image: 'images/steven.png' }
],
kanbanColumns: [
{ text: 'Backlog', dataField: 'new', access: 'none', maxItems: 5 },
{ text: 'In Progress', dataField: 'work', access: 'none', maxItems: 5 },
{ text: 'Done', dataField: 'done', access: 'none', maxItems: 5, collapseDirection: 'right' }
],
kanbanSource: [
{ id: 3, status: 'done', text: 'Combine Orders', tags: 'orders, combine', color: '#5dc3f0', resourceId: 3 },
{ id: 4, status: 'work', text: 'Change Billing Address', tags: 'billing', color: '#6bbd49', resourceId: 1 },
{ id: 5, status: 'new', text: 'One item added to the cart', tags: 'cart', color: '#5dc3f0', resourceId: 3 },
{ id: 6, status: 'work', text: 'Login 404 issue', tags: 'issue, login', color: '#6bbd49' }
]
}
}

Events

The events in Vue are set as an attribute with @ prefix, for example:

<JqxKanban @columnAttrClicked="onColumnAttrClick()"
:width="400" :height="400"
:columns="kanbanColumns" :resources="staff"
:source="kanbanSource">
</JqxKanban>

All events that are bound to a component are implemented in the methods member of the Vue class.

methods: {
onColumnAttrClick: function () {
// Do something...
}
}

Methods

To use a component's method we should have its reference. In Vue we refer to a component by the special $refs property. Before that we need to add the desired name reference to that component:

<JqxKanban ref="kanban"></JqxKanban>

Here how you can use a component's method:

this.$refs.kanban.getItems();

If we want to add additional methods we should also implement them in the methods member.

In case we need to do some precalculation or something else before the components are rendered, we should use the beforeCreate member. It depends on the case.

If you have followed the above steps, you App.vue file would look like this:

App.vue:

Kanban Example

<template>
<div>
<JqxKanban @itemMoved="myKanbanOnItemMoved($event)"
@columnCollapsed="myKanbanOnColumnCollapsed($event)"
@columnExpanded="myKanbanOnColumnExpanded($event)"
@itemAttrClicked="myKanbanOnItemAttrClicked($event)"
@columnAttrClicked="myKanbanOnColumnAttrClicked($event)"
:width="width" :source="dataAdapter" :columns="columns"
:resources="resourcesAdapterFunc()">
</JqxKanban>
<div ref="myLog"></div>
</div>
</template>
<script>
import JqxKanban from "jqwidgets-scripts/jqwidgets-vue/vue_jqxkanban.vue";
export default {
components: {
JqxKanban,
},
data: function () {
return {
width: 400,
dataAdapter: new jqx.dataAdapter(this.source),
columns: [
{ text: 'Backlog', dataField: 'new' },
{ text: 'In Progress', dataField: 'work' },
{ text: 'Done', dataField: 'done' }
]
}
},
beforeCreate: function () {
this.log = [];
const fields = [
{ name: 'id', type: 'string' },
{ name: 'status', map: 'state', type: 'string' },
{ name: 'text', map: 'label', type: 'string' },
{ name: 'tags', type: 'string' },
{ name: 'color', map: 'hex', type: 'string' },
{ name: 'resourceId', type: 'number' }
];
this.source = {
localData: [
{ id: '1161', state: 'new', label: 'Make a new Dashboard', tags: 'dashboard', hex: '#36c7d0', resourceId: 3 },
{ id: '1645', state: 'work', label: 'Prepare new release', tags: 'release', hex: '#ff7878', resourceId: 1 },
{ id: '9213', state: 'new', label: 'One item added to the cart', tags: 'cart', hex: '#96c443', resourceId: 3 },
{ id: '6546', state: 'done', label: 'Edit Item Price', tags: 'price, edit', hex: '#ff7878', resourceId: 4 },
{ id: '9034', state: 'new', label: 'Login 404 issue', tags: 'issue, login', hex: '#96c443' }
],
dataType: 'array',
dataFields: fields
};
},
methods: {
resourcesAdapterFunc: function () {
let resourcesSource =
{
localData: [
{ id: 0, name: 'No name', image: 'images/common.png', common: true },
{ id: 1, name: 'Andrew Fuller', image: 'images/andrew.png' },
{ id: 2, name: 'Janet Leverling', image: 'images/janet.png' },
{ id: 3, name: 'Steven Buchanan', image: 'images/steven.png' },
{ id: 4, name: 'Nancy Davolio', image: 'images/nancy.png' },
{ id: 5, name: 'Michael Buchanan', image: 'images/Michael.png' },
{ id: 6, name: 'Margaret Buchanan', image: 'images/margaret.png' },
{ id: 7, name: 'Robert Buchanan', image: 'images/robert.png' },
{ id: 8, name: 'Laura Buchanan', image: 'images/Laura.png' },
{ id: 9, name: 'Laura Buchanan', image: 'images/Anne.png' }
],
dataType: 'array',
dataFields: [
{ name: 'id', type: 'number' },
{ name: 'name', type: 'string' },
{ name: 'image', type: 'string' },
{ name: 'common', type: 'boolean' }
]
};
let resourcesDataAdapter = new jqx.dataAdapter(resourcesSource);
return resourcesDataAdapter;
},
updateLog: function () {
let count = 0;
let str = '';
for (let i = this.log.length - 1; i >= 0; i--) {
str += this.log[i] + '<br/>';
count++;
if (count > 10)
break;
}
this.$refs.myLog.innerHTML = str;
},
myKanbanOnItemMoved: function (event) {
let args = event.args;
let itemId = args.itemId;
let oldParentId = args.oldParentId;
let newParentId = args.newParentId;
let itemData = args.itemData;
let oldColumn = args.oldColumn;
let newColumn = args.newColumn;
this.log.push('itemMoved is raised');
this.updateLog();
},
myKanbanOnColumnCollapsed: function (event) {
let args = event.args;
let column = args.column;
this.log.push('columnCollapsed is raised');
this.updateLog();
},
myKanbanOnColumnExpanded: function (event) {
let args = event.args;
let column = args.column;
this.log.push('columnExpanded is raised');
this.updateLog();
},
myKanbanOnItemAttrClicked: function (event) {
let args = event.args;
let itemId = args.itemId;
let attribute = args.attribute; // template, colorStatus, content, keyword, text, avatar
this.log.push('itemAttrClicked is raised');
this.updateLog();
},
myKanbanOnColumnAttrClicked: function (event) {
let args = event.args;
let column = args.column;
let cancelToggle = args.cancelToggle; // false by default. Set to true to cancel toggling dynamically.
let attribute = args.attribute; // title, button
this.log.push('columnAttrClicked is raised');
this.updateLog();
}
}
}
</script>
<style>
</style>

Run Code