:: Forum >>

UI.Combo & UI.List: Add items to control - performance

See,

function LoadCountries()
{
/* AJAX request */
/* return array of objects */

countries = [{"id":"1", "name": "USA"},"id":"2", "name": "Canada"},..]
for (var i=0;i<countries.length; i++)
{
CountryComboBox.setItemText(countries[i].name, i);
}
CountryComboBox.setItemCount(countries.length);
}

If the number of items is big enough (say, above 1000), this code performs very slowly.

Can I add items to the "UI.Combo" (and "UI.List") any other way?

Thanks


Michael
Thursday, November 30, 2006
You can rearrange the text into an array and assign the complete array -

var countries = [{"id":"1", "name": "USA"},"id":"2", "name": "Canada"},..];
var names = [];

for (var i=0;i<countries.length; i++){
names[i] = countries[i].name;
}

CountryComboBox.setItemText(names);
CountryComboBox.setItemCount(names.length);
Alex (ActiveWidgets)
Thursday, November 30, 2006

This topic is archived.


Back to support forum

Forum search