adgfs
adgfs

Reputation: 423

Sort multiselect in dojo/dijit

My question is - is there any way in dojo/dijit multiselect to sort the options or i have to do it manual?

Thanks

Edit:

So far i solved my problem using a sort algorithm. In case someone need it

function sortSelect(selElem) {
        var tmpAry = new Array();
        for (var i=0;i<selElem.options.length;i++) {
                tmpAry[i] = new Array();
                tmpAry[i][0] = selElem.options[i].text;
                tmpAry[i][1] = selElem.options[i].value;
        }
        tmpAry.sort();
        while (selElem.options.length > 0) {
            selElem.options[0] = null;
        }
        for (var i=0;i<tmpAry.length;i++) {
                var op = new Option(tmpAry[i][0], tmpAry[i][1]);
                selElem.options[i] = op;
        }
        return;
}

Upvotes: 1

Views: 1147

Answers (1)

Adam Skoog
Adam Skoog

Reputation: 31

What you have there is what I have had to do for sorting, there is no built in way for the multiselect to do sorting, unless they added it with 1.7 having just been released.

Upvotes: 1

Related Questions