wenzhixin / multiple-select

A jQuery plugin to select multiple elements with checkboxes :)
http://multiple-select.wenzhixin.net.cn
MIT License
1.91k stars 652 forks source link

Pre selected option not visible without scrolling #563

Open andi-b opened 3 years ago

andi-b commented 3 years ago

It would be good that if there's already an option selected that when you open the dropdown, the selected value is visible without scrolling. I've been able to do this when there are less than 200 options, but not if the selected option is in the hidden group over 200 options.

prlama55 commented 1 year ago

The following piece of code works for me. styler: function (row) { if(row.selected) { $([data-key=${row._key.trim()}]).prop("checked", true); // Mark checked for selected checkbox value $([data-key=${row._key.trim()}]).closest("li").addClass("selected"); // NOT mandatory. Added class to make consistency while rendering dropdownlist } else { $([data-key=${row._key.trim()}]).prop("checked", false); // Unmark checked for selected checkbox value $([data-key=${row._key.trim()}]).closest("li").removeClass("selected"); } },