我有循环:
for (var key in myMap) {
if (myMap.hasOwnProperty(key)) {
propertiesPanel.add(new Ext.form.Label({
text: key+':'+myMap[key]
}));
propertiesPanel.doLayout();
}
}
但是如果我在hashmap myMap中有500个键,它会将所有标签添加到面板,最后刷新过程发生。但我想逐渐看到添加过程。我怎么能这样做?
答案 0 :(得分:1)
尝试递归函数
而不是循环addFields(500); //Adding 500 fields
fieldsAdded = 0
addFields = function(fieldCount) {
propertiesPanel.add(new Ext.form.Label({
text: 'Some text'
}));
propertiesPanel.doLayout();
fieldsAdded++;
if (fieldsAdded < fieldCount) {
Ext.Function.defer(function() {
addFields(fieldCount)
}, 100, this);
}
}