我正在尝试在 ExtJS 4.2 中加载记录时加载和刷新网格。不幸的是,在一个紧密的循环中,while (i--) 等到所有记录都加载完毕后再渲染 UI,基本上是阻塞的。我需要在加载每条记录时渲染 UI,因为我有大量记录要加载,因为微调器会旋转一分钟。
有什么办法可以触发刷新并继续加载它们..或者以2秒的间隔触发刷新?或每10条记录..
这是我的代码:
// In the parent function:
while (i--)
{
gr.l('ao', 'Running pool');
me.drawCell(store, rList[i]);
// need to refresh the grid at this point ..
// printing console.log outputs but UI is not refreshed ..
}
// The function which does the adding to the store ..
drawCell: function (store, roster)
{
var me = this;
if (!roster)
return false;
// fix the common issues
firstName = roster.firstName ? roster.firstName : roster.userId;
lastName = roster.lastName ? roster.lastName : '';
companyName = roster.companyName ? roster.companyName : '';
phoneNumbers = me.localStore.getPhoneNumbers(roster);
userId = roster.userId;
// add to list
store.add(
{
firstName: firstName,
firstNameGroup: firstName.charAt(0).toUpperCase(),
userId: userId,
lastName: lastName,
companyName: companyName,
iconCls: 'avatar-' + userId,
status: (roster.status == 'offline') ? 'offline':roster.status,
locationStatus: 'office',
locationStatusDetail: 'Office',
icon: me.getAvatarUrl(userId),
systemMetadata: roster.systemMetadata,
middleInitials: roster.middleInitials,
userMetadata: roster.userMetadata,
statusGroup: me.getStatusGroup(roster.status),
group: (roster.systemMetadata && roster.systemMetadata.tags &&
});
},