简体   繁体   English

有没有办法在“ resumelayouts”事件处理完成后立即调用函数?

[英]Is there a way to call a function right after 'resumelayouts' event processing finishes?

I change width for dozens gridpanel columns. 我更改了数十个gridpanel列的宽度。 I want to show a mask while it is performing. 我想在表演时放一个面具。

grid.setLoading(true);
Ext.suspendLayouts();
// columns -- grid columns
columns.forEach(function (column) {
    column.setWidth(...);
}, this);
// fires 'resumelayouts' event and immediately returns.
Ext.resumeLayouts();
// performs before everything updates its layout, which takes 3-4 seconds.
grid.setLoading(false);

The problem is that you end up tying up the current "thread" so the browser doesn't get a chance to repaint. 问题是您最终会占用当前的“线程”,因此浏览器没有机会重新绘制。 You could do something like this: 您可以执行以下操作:

grid.setLoading(true);
setTimeout(function() {
    Ext.suspendLayouts();
    columns.forEach(function (column) {
        column.setWidth(...);
    }, this);
    Ext.resumeLayouts();
    grid.setLoading(false);
}, 1);

The above relinquishes control from the current "thread" and allows the repaint before it begins the layout operation. 上面的代码放弃了当前“线程”的控件,并允许在开始布局操作之前进行重新绘制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM