lundi 28 janvier 2019

Is there a way to tweak 'Select Multiple' so that it shows '1 selected' or '2 selected' instead of the values?

I am using Select2 in my application and I have run into a problem.

I need a typeahead select box which supports multiple selections with checkboxes and on selecting, shows " selected."

The problem is, there's existence of a dropdown list which supports this BUT it is not typeahead in nature AND there's a typeahead select box supporting this BUT it shows the selected values instead of '1 selected', '2 selected', etc.

Please refer to https://jsfiddle.net/wasikuss/7ak9skbb/ to understand my problem better. I need a combination of the 2nd and 3rd select boxes.

$('.select2-multiple2').select2MultiCheckboxes({
templateSelection: function(selected, total) {
  return "Selected " + selected.length + " of " + total;
}
})

$('.select2-original').select2({
  placeholder: "Choose elements",
  width: "100%"
})

Hope I am clear enough.




Aucun commentaire:

Enregistrer un commentaire