Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Select All in webdropdown
posted

Hello,

I have a problem with the multiselect on a webdropdown: I added a script that allows me to select/uselect all items in the dropdown.

function selectedIndexChanged(sender, eventArgs) {

        var activeIndex = sender.get_activeItemIndex();

        var items = sender.get_items();

 

        if (activeIndex == 0 && items.getItem(0).get_selected() == true) {

            for (i = 1; i < items.getLength(); i++) {

                var item = items.getItem(i);

                item.select();

            }           

        }

        else if (activeIndex == 0 && items.getItem(0).get_selected() == false) {

            for (i = 1; i < items.getLength(); i++) {

                var item = items.getItem(i);

                item.unselect();

            }

        }

        else if (activeIndex != 0) {

            if (items.getItem(activeIndex).get_selected() == false) {

                items.getItem(0).unselect();

            }

        }

    }

My problem is that when I select 'All', the 'All' string appears in the text of the dropdown along with all the other selected elements.

I would like to set the text to "All" without having the full list of elements.

Any idea?

Thank you in advance.

Sandro