Angular UI Components Documentation
The Angular Sortable enables users to change the position of elements through drag and drop. This guide adds the Angular Sortable (jqxSortable) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-ngjqwidgets-ng/jqxsortable 
In an Angular project (to start one, see Getting started with Angular), add the package with the Angular CLI. It asks for a theme and adds the styles to angular.json:
ng add jqwidgets-ng
Components are standalone: add jqxSortableModule to the imports of the component that uses it.
import { Component } from '@angular/core';
import { jqxSortableModule } from 'jqwidgets-ng/jqxsortable';
@Component({
selector: 'app-root',
imports: [jqxSortableModule],
templateUrl: './app.html'
})
export class App {}
The source of the live Default Functionality demo.
<jqxSortable #mySortable></jqxSortable>
import { Component, AfterViewInit, ViewEncapsulation, viewChild } from '@angular/core';
import { jqxSortableComponent } from 'jqwidgets-ng/jqxsortable';
import { CommonModule } from '@angular/common';
import { jqxSortableModule } from 'jqwidgets-ng/jqxsortable';
@Component({
imports: [CommonModule, jqxSortableModule],
selector: 'app-root',
templateUrl: './app.html',
styleUrl: './app.css',
encapsulation: ViewEncapsulation.None
})
export class App implements AfterViewInit {
readonly mySortable = viewChild.required<jqxSortableComponent>('mySortable');
ngAfterViewInit(): void {
this.loadInfo();
}
loadInfo(): void {
let firstNames = ['Nancy', 'Andrew', 'Janet', 'Margaret', 'Steven'];
let lastNames = ['Davolio', 'Fuller', 'Leverling', 'Peacock', 'Buchanan'];
let titles = [
'Sales Representative',
'Vice President, Sales',
'Sales Representative',
'Sales Representative',
'Sales Manager'
];
for (let i = 0; i < firstNames.length; i++) {
let element = document.createElement('div');
let imgurl =
'https://www.jqwidgets.com/angular/images/' + firstNames[i].toLowerCase() + '.png';
let img = '<img height="50" width="40" src="' + imgurl + '"/>';
element.innerHTML =
'<table style="min-width: 130px;"><tr><td style="width: 40px;" rowspan="2">' +
img +
'</td><td>' +
firstNames[i] +
' ' +
lastNames[i] +
'</td></tr><tr><td>' +
titles[i] +
'</td></tr></table>';
this.mySortable().elementRef.nativeElement.firstElementChild.appendChild(element);
}
}
}
jqxSortable > div {
margin: 2px;
padding: 5px;
float: left;
width: 200px;
border: lightblue solid 1px;
}
jqxSortable > div > div {
border-radius: 5px;
padding: 5px;
cursor: pointer;
background-color: white;
color: black;
border: 1px solid transparent;
}
jqxSortable > div > div:hover {
border: 1px solid #356AA0;
}
Options are inputs, bound with [name]="value".
Events are outputs named on plus the event name with a capital first letter. For example, change: This event is triggered when the DOM position of an item is changed.
<jqxSortable (onChange)="onChange($event)"></jqxSortable>
onChange(event: any): void {
console.log(event.args);
}
Get the component with a signal query and call its methods. For example, refresh: Refresh the items.
<jqxSortable #mySortable></jqxSortable>
import { Component, viewChild } from '@angular/core';
import { jqxSortableModule, jqxSortableComponent } from 'jqwidgets-ng/jqxsortable';
@Component({
selector: 'app-root',
imports: [jqxSortableModule],
templateUrl: './app.html'
})
export class App {
readonly mySortable = viewChild.required<jqxSortableComponent>('mySortable');
run(): void {
this.mySortable().refresh();
}
}