Getting Started with the Kendo UI for Vue Native ListBox

This guide provides essential information about using the Kendo UI for Vue Native ListBox package—you will learn how to install the ListBox package, add a ListBox component to your project, style the component, and activate your license.

The ListBox Package is part of Kendo UI for Vue, a professional grade UI library with 100+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.

After completing this guide, you will be able to reproduce the following example.

Example
View Source
Change Theme:

Setting Up Your Vue Project

Before you install the Kendo UI for Vue Native ListBox, make sure that you have a running Vue project. The easiest way to set up a Vue project is to use the approach described in the Set up the Vue project section of the First Steps with JavaScript article.

Installing the ListBox Package

All Kendo UI for Vue Native packages are distributed through npm and offer a similar installation experience. To use the ListBox component, start with the installation of the ListBox npm package and its dependencies. Use Node.js v5.0.0 or later.

npm install --save @progress/kendo-vue-listbox @progress/kendo-licensing @progress/kendo-svg-icons

Importing the Component

After installing the package, import the ListBox component in the Vue App. To provide a flawless data transfer between multiple ListBox components, import the processListBoxData method.

In the src/App.vue file of your Vue project, import the ListBox component from the ListBox package.

// ES2015 module syntax
import { ListBox } from "@progress/kendo-vue-listbox";
// CommonJS format
const { ListBox } = require('@progress/kendo-vue-listbox');

Using the Component

  1. Import the data file in the src/App.vue file.

      import { data } from './data';
  2. Define the variables that will hold the data for the two ListBox components.

      data() {
        return {
          employees: data,
          developers: [],
        };
      }
  3. Set the selectField value. That value will determine which items are selected.

      const SELECTED_FIELD = 'selected';
      .....
      data() {
        return {
          SELECTED_FIELD,
          ......
        };
      }
  4. Add a handler for the onItemClick event of the ListBox. It is needed select or deselect items.

      handleItemClick(event, data, connectedData) {
        this[data] = this[data].map((item) => {
          if (item.name === event.dataItem.name) {
            item[SELECTED_FIELD] = !item[SELECTED_FIELD];
          } else if (!event.ctrlKey) {
            item[SELECTED_FIELD] = false;
          }
          return item;
        });
        this[connectedData] = this[connectedData].map((item) => {
          item[SELECTED_FIELD] = false;
          return item;
        });
      }
  5. Add a handler for the onToolClick event of the ListBoxToolbar. It is needed to update the lists.

      handleToolBarClick(e) {
        let toolName = e.toolName || '';
        let result = processListBoxData(
          this.employees,
          this.developers,
          toolName,
          SELECTED_FIELD
        );
    
        this.employees = result.listBoxOneData;
        this.developers = result.listBoxTwoData;
      }
  6. Add the markup of the two components to the template section of the src/App.vue file in your project.

    <div class="container">
        <div class="row justify-content-center">
        <div class="col">
            <h6>Employees</h6>
            <ListBox
            :style="{ height: '400px', width: '100%' }"
            :dataItems="employees"
            :text-field="'name'"
            :selectedField="SELECTED_FIELD"
            :draggable="false"
            @itemclick="itemClick"
            :toolbar="'toolbar'"
            >
            <template v-slot:toolbar>
                <ListBoxToolbar
                :tools="[
                    'moveUp',
                    'moveDown',
                    'transferTo',
                    'transferFrom',
                    'transferAllTo',
                    'transferAllFrom',
                    'remove',
                ]"
                :dataItems="employees"
                :dataConnected="developers"
                @toolclick="handleToolBarClick"
                />
            </template>
            </ListBox>
        </div>
        <div class="col">
            <h6>Developers</h6>
            <ListBox
            :style="{ height: '400px', width: '100%' }"
            :dataItems="developers"
            :textField="'name'"
            :selectedField="SELECTED_FIELD"
            @itemclick="itemClick2"
            />
        </div>
        </div>
    </div>
  7. To style the ListBox, install and import the Default theme, which is one of the four beautiful themes for Kendo UI for Vue.

    1. Install the Default theme package.

      npm install --save @progress/kendo-theme-default
    2. Import the Theme package in src/App.vue..

      import '@progress/kendo-theme-default';
  8. Build, run and test the application by typing the following command in the root folder of your project:

    npm run dev

Activating Your License Key

Using any of the UI components in the Kendo UI for Vue Native library requires either a commercial license key or an active trial license key.

Follow the instructions on the My License page to activate your trial or commercial license. You can skip this step if your application already contains a Kendo UI for Vue license file.

Dependencies

The ListBox package requires you to install the following peer dependencies in your application:

Package NameDescription
vue 2.6.14 or 3.0.0+Contains the functionality necessary to define Vue components.
@progress/kendo-licensingContains the internal infrastructure related to licensing.
@progress/kendo-svg-iconsContains the svg icons for the components.
@progress/kendo-vue-buttonsContains the definitions of all Button components available in the Kendo UI for Vue Native suite.

Vue 2 is currently in its end-of-support phase till Nov 2024. After our last major release for 2024, Vue 2 will no longer be supported in the new versions of the Kendo UI for Vue components. Please check our Vue 2 End of Support article for more details.

Learning Resources