【发布时间】:2013-07-17 19:36:09
【问题描述】:
我正在尝试在 ExtJS 4.2 中加载记录时加载和刷新网格。 不幸的是,在一个紧密的循环中,while (i--) 等到 ALL 记录在渲染 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 &&
});
},
【问题讨论】:
-
你到底为什么要这样做?这将导致 ExtJS 每次将记录添加到网格时重新绘制。你会看到一个巨大的性能下降。如果您的记录太多并且导致 UI 挂起,请尝试使用 Infinite Grid 或 Paging Grid。
标签: loops extjs user-interface grid store