Select a panel on the right and use the up and down arrows to change its position. The preview follows the order of the selected list.
Select a panel on the right and use the up and down arrows to change its position. The preview follows the order of the selected list.
jqxPickList with reorderable: true adds Move up and Move down buttons for the selected list, so the order of the selection means something - here, the order of the panels on a dashboard. getSelectedValues() returns the items in the order shown.
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.reorderable property – Sets or gets whether the selected list can be reordered.change event – This event is triggered when the selected items change.getSelectedValues method – Returns the values 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 dashboard with a fixed set of panels. The user chooses which to show AND in
// what order: the selected list's order is the layout, and Move up / Move down
// rearrange it. The preview below re-renders from getSelectedValues().
var panels = [
'Revenue', 'New customers', 'Open orders', 'Conversion rate', 'Support tickets',
'Top products', 'Sales by region', 'Inventory alerts', 'Team activity', 'Churn'
];
$('#jqxPickList').jqxPickList({
width: 640,
height: 320,
source: panels,
selectedItems: ['Revenue', 'Open orders', 'Top products', 'Support tickets'],
sourceHeader: 'Available panels',
targetHeader: 'Dashboard, top to bottom',
reorderable: true
});
var preview = function () {
var order = $('#jqxPickList').jqxPickList('getSelectedValues');
var board = $('#board').empty();
if (!order.length) {
board.append('<div class="empty">No panels selected</div>');
return;
}
$.each(order, function (i, name) {
board.append($('<div></div>').append($('<span></span>').text('Panel ' + (i + 1))).append(document.createTextNode(name)));
});
};
$('#jqxPickList').on('change reordered', preview);
preview();
});
<div id="content">
<div class="demo">
<p class="demo-hint">
Select a panel on the right and use the up and down arrows to change its position. The preview follows the order of the selected list.
</p>
<div id="jqxPickList"></div>
<div class="demo-preview">
<strong>Dashboard preview</strong>
<div id="board" class="demo-board"></div>
</div>
</div>
</div>