multi-select
multi-select copied to clipboard
Select all current items in filtered list
How do I select all of the current filtered items after search filter is applied?
If you look at the searchable demo on the site, you can select all filtered items with:
$('#ms-511multiselect .ms-selectable .ms-list li[style=""]'). All filtered elements have the style attribute empty, while the others are not visible (display:none).
In my case it is: $("#ms-pre-selected-options .ms-elem-selection.ms-selected") but if you want to see a Value as well as Text property, add a custom attribute with your value to an option markup.
Assuming your select has a select-list id and "Select all" button has a select-all id, you can do the following:
$('#select-all').click(function(){
$('#ms-select-list .ms-elem-selectable').not(':hidden').each(function() {
$('#select-list').multiSelect('select', [$(this).data('ms-value')]);
});
return false;
});
What it does is going through the items in the selectable list, except the filtered ones (which are hidden), and add them to the selected list.