Getting Started with the Kendo UI for Angular Sortable

The Sortable provides a sortable drag-and-drop functionality to elements within a list.

Basic Usage

The following example demonstrates the Sortable in action.

Example
View Source
Edit In Stackblitz  
Change Theme:

Installation

Either use the quick setup (Angular CLI) or manually add the package.

Quick Setup with Angular CLI

Angular CLI supports the addition of packages through the ng add command which executes in one step the set of otherwise individually needed commands.

    ng add @progress/kendo-angular-sortable

Manual Setup

  1. Download and install the package.

       npm install --save @progress/kendo-angular-sortable @progress/kendo-angular-l10n @progress/kendo-angular-common @progress/kendo-licensing
  2. Once installed, import the SortableModule in your application root or feature module.

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    import { SortableModule } from '@progress/kendo-angular-sortable';
    import { AppComponent } from './app.component';
    
    @NgModule({
        bootstrap:    [AppComponent],
        declarations: [AppComponent],
        imports:      [BrowserModule, BrowserAnimationsModule, SortableModule]
    })
    export class AppModule {
    }
  3. You are required to install one of the Kendo UI themes for Angular to style your component. For more information on how to add the styles, refer to the section on styling.

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

Dependencies

The Sortable package requires the following peer dependencies that have to be installed by your application:

  • @angular/common
  • @angular/core
  • @progress/kendo-angular-l10n
  • @progress/kendo-angular-common
  • @progress/kendo-licensing
  • rxjs

The Sortable package utilizes the Angular animation system, which supports a specific set of browsers.

Functionality and Features

Events

The following example demonstrates basic Sortable events.

Known Limitations

To enable the reordering of items, mark some of the elements in the item template as draggablefor example, button and a.

import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  template: `
    <kendo-sortable [kendoSortableBinding]="items">
      <ng-template let-item="item">
        <button draggable="true">
          {{item}}
        </button>
      </ng-template>
    </kendo-sortable>
  `
})
export class AppComponent {
  public items: string[] = [
    'Item 1', 'Item 2', 'Item 3', 'Item 4'
  ];
}