Click an item to select it, Ctrl+click or Shift+click for several, then use the arrows. Double-clicking an item moves it straight across.
Click an item to select it, Ctrl+click or Shift+click for several, then use the arrows. Double-clicking an item moves it straight across.
jqxPickList is a dual-list picker: users move items between an available list and a selected list with the transfer buttons, a double-click, or the keyboard. This demo picks the columns of a report.
A live JavaScript/jQuery example of jqxPickList, the jQWidgets PickList component, with its complete source code below. It is one of 7 jqxPickList demos for jQuery.
width property – Sets or gets the width of the widget.height property – Sets or gets the height of the widget.source property – Sets or gets the pool of available items.selectedItems property – Sets or gets the values that start in the Selected list.sourceHeader property – Sets or gets the header text of the available list.targetHeader property – Sets or gets the header text of the selected list.change event – This event is triggered when the selected items change.getSelectedItems method – Returns the items currently in the selected list, in order.To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $.
The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxbuttons.js, jqxscrollbar.js, jqxlistbox.js, jqxpicklist.js.
It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers).
$(document).ready(function () {
// A report builder: every column the data set has on the left, the columns the
// report will show on the right. The picker keeps the two lists in sync and
// reports the selection through its change event.
var columns = [
'Order ID', 'Customer', 'Company', 'Country', 'City', 'Product', 'Category',
'Quantity', 'Unit price', 'Discount', 'Total', 'Order date', 'Ship date',
'Status', 'Sales rep', 'Region'
];
$('#jqxPickList').jqxPickList({
width: 620,
height: 340,
source: columns,
selectedItems: ['Order ID', 'Customer', 'Product', 'Total', 'Order date'],
sourceHeader: 'Available columns',
targetHeader: 'Report columns'
});
var showSelection = function () {
var selected = $('#jqxPickList').jqxPickList('getSelectedItems');
$('#selection').text(selected.length ? selected.join(', ') : 'No columns selected - the report would be empty.');
};
$('#jqxPickList').on('change', showSelection);
showSelection();
});
<div id="content">
<div class="demo">
<p class="demo-hint">
Click an item to select it, <kbd>Ctrl</kbd>+click or <kbd>Shift</kbd>+click for several,
then use the arrows. Double-clicking an item moves it straight across.
</p>
<div id="jqxPickList"></div>
<div class="demo-result">
<strong>Report columns, in order</strong>
<span id="selection"></span>
</div>
</div>
</div>