I found the client-side sorting method in one of the answers to not work as expected. So I changed it and came up with following method, that I found worked perfectly. The second parameter of sortOrder can be either 'asc' or 'desc'.
function
sortByItemText(comboBox, sortOrder) {
comboBox.trackChanges();
var
items = comboBox.get_items();
var
tempArray = items._array;
if
(sortOrder ===
"asc"
) {
tempArray.sort(
function
(a, b) {
if
(a && b && a.get_text() > b.get_text())
return
1;
if
(a && b && a.get_text() === b.get_text())
return
0;
if
(a && b && a.get_text() < b.get_text())
return
-1;
});
}
else
{
tempArray.sort(
function
(a, b) {
if
(a && b && a.get_text() > b.get_text())
return
-1;
if
(a && b && a.get_text() === b.get_text())
return
0;
if
(a && b && a.get_text() < b.get_text())
return
1;
});
}
items.clear();
for
(
var
i = 0; i < tempArray.length; i++) {
var
comboItem =
new
Telerik.Web.UI.RadComboBoxItem();
comboItem.set_text(tempArray[i].get_text());
comboItem.set_value(tempArray[i].get_value());
items.insert(i, comboItem);
}
comboBox.commitChanges();
return
;
}