Vue UI Components Documentation
The Vue Sortable enables users to change the position of elements through drag and drop. This guide adds the Vue Sortable (jqxSortable) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-scriptsjqwidgets-scripts/jqwidgets-vue3/vue_jqxsortable.vue 
In a Vue 3 project (to start one, see Getting started with Vue), add the package:
npm install jqwidgets-scripts
import JqxSortable from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxsortable.vue';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.base.css';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.tailwind-blue-dark.css';
With <script setup>, an imported component is ready to use in the template. jqx.base.css is required; the second file is a theme, selected with the theme attribute.
The Default Functionality demo as a Single-File Component:
<template>
<JqxSortable ref="mySortable"></JqxSortable>
</template>
<script setup>
import { onMounted, ref } from 'vue';
import JqxSortable from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxsortable.vue';
const mySortable = ref(null);
const firstNames = ref(['Nancy', 'Andrew', 'Janet', 'Margaret', 'Steven']);
const lastNames = ref(['Davolio', 'Fuller', 'Leverling', 'Peacock', 'Buchanan']);
const titles = ref([
'Sales Representative',
'Vice President, Sales',
'Sales Representative',
'Sales Representative',
'Sales Manager'
]);
function loadInfo() {
for (let i = 0; i < firstNames.value.length; i++) {
const element = document.createElement('div');
const imgurl =
'https://www.jqwidgets.com/vue/images/' + firstNames.value[i].toLowerCase() + '.png';
const 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.value[i] +
' ' +
lastNames.value[i] +
'</td></tr><tr><td>' +
titles.value[i] +
'</td></tr></table>';
mySortable.value.$el.appendChild(element);
}
}
onMounted(() => {
loadInfo();
});
</script>
<style>
.jqx-sortable {
margin: 2px;
padding: 5px;
float: left;
width: 200px;
border: lightblue solid 1px;
}
.jqx-sortable > div {
border-radius: 5px;
padding: 5px;
cursor: pointer;
background-color: white;
color: black;
border: 1px solid transparent;
}
.jqx-sortable div:hover {
border: 1px solid #356aa0;
}
</style>
Options are attributes. Bind values from the script with :, for example :width="850".
Listen to an event with @ and its name. For example, change: This event is triggered when the DOM position of an item is changed.
<script setup>
function onChange(event) {
console.log(event.args);
}
</script>
<template>
<JqxSortable @change="onChange" />
</template>
Call methods through a template ref. For example, refresh: Refresh the items.
<script setup>
import { ref, onMounted } from 'vue';
const mySortable = ref(null);
onMounted(() => {
mySortable.value.refresh();
});
</script>
<template>
<JqxSortable ref="mySortable" />
</template>
Every component also has setOptions({ … }) and getOptions('name').