Multiple Selection with Shift Key

Hi All,

is there anyway to enable bulk selection with Shift key? There is a similar case on github.

I tried adding below code sample to my selection but even though I could use shift key to select multiple options, I lost select2 dynamic features?

var count_shift = 0;
var shift_array = [];
var options_selected = [];
$j(".assigneeSelection").on(“select2:select”, function (e) {
if (e.shiftKey) {
shift_array.push(e.params.data.element.index);
count_shift++;
}
if( count_shift == 2 ){
for (var i = shift_array[0]; i <= shift_array[1]; i++) {
var option_value = $j(’.select2-shift option’).eq(i).val();
options_selecteds.push(option_value);
}
$j(’.select2-shift’).val(options_selecteds);
$j(’.select2-shift’).trigger(‘change’);
$j(’.select2-shift’).select2(‘close’);
count_shift = 0;
shift_array = [];
options_selecteds = [];
}
});

Hi, Ozkan—

What do you mean by “lose Select2’s dynamic features”? What features do you lose?

Also, note that your code will break if the second item the user selects has an index that is lower than the first item they selected (i.e., if shift_array[1] < shift_array[0]).