Documentation
jqxPickList is a dual-list picker, also called a shuttle or transfer list: the available items on the left, the selected items on the right, and buttons, a double-click or the keyboard to move items across. Use it to pick a subset from a set, such as the columns of a report or the members of a team. Both lists are jqxListBox instances, so filtering, checkboxes and item templates work in the pick list too.
jqwidgets-scripts5 scripts, listed below
Load the styles and the PickList's scripts - from the jsDelivr CDN as here, or from node_modules/jqwidgets-scripts/jqwidgets/ after npm install jqwidgets-scripts. jQuery is optional: jqxcore.js works on its own.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/styles/jqx.fluent.css">
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxcore.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxbuttons.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxscrollbar.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxlistbox.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxpicklist.js"></script>
Then create it on an element with $('#pickList').jqxPickList({ … }). The live demos show every option with its source code; the guide below explains them.
Add an element for the widget:
<div id="pickList"></div>
Then create the widget on it. source is the pool of items, and selectedItems lists the ones that start in the selected list:
$('#pickList').jqxPickList({
width: 620,
height: 340,
source: ['Order ID', 'Customer', 'Company', 'Country', 'Product', 'Quantity', 'Total', 'Order date'],
selectedItems: ['Order ID', 'Customer', 'Total'],
sourceHeader: 'Available columns',
targetHeader: 'Report columns'
});
With an array of objects, displayMember names the field shown as the item's label and valueMember the field that identifies it. selectedItems then lists values:
$('#pickList').jqxPickList({
source: [
{ id: 1, name: 'Anna Smith' },
{ id: 2, name: 'Peter Brown' },
{ id: 3, name: 'Maria Garcia' }
],
displayMember: 'name',
valueMember: 'id',
selectedItems: [2],
filterable: true,
showCounts: true
});
source also accepts a jqx.dataAdapter instance.
Pass an object to change options after the widget is created, and an option's name to read it:
$('#pickList').jqxPickList({ checkboxes: true, reorderable: true });
const header = $('#pickList').jqxPickList('targetHeader');
checkboxes selects items with check boxes; reorderable adds move up and move down buttons to the selected list.
change is raised whenever items move between the lists. Its event.args carries added, removed and the new selectedItems:
$('#pickList').on('change', function (event) {
console.log(event.args.added, event.args.removed, event.args.selectedItems);
});
itemsAdded and itemsRemoved are raised for each transfer, and reordered when the selected list is rearranged; each carries the items it concerns in event.args.items.
Call a method by passing its name, followed by its arguments:
// the items in the selected list, in order
const items = $('#pickList').jqxPickList('getSelectedItems');
// move values across (one value or an array)
$('#pickList').jqxPickList('add', ['Product', 'Quantity']);
$('#pickList').jqxPickList('remove', 'Customer');
// read or replace the selection by value
const values = $('#pickList').jqxPickList('val');
$('#pickList').jqxPickList('val', ['Order ID', 'Total']);
addAll and removeAll move every item, and getSource returns the items left in the available list.