:: Forum >>

Delay refreshing the grid while resizing columns

When the user resizes the window, I resize the grid and adjust each column (using the obj.setColumnWidth function). However, for each column I resize, each row get rendered so on a 5 col grid, each row gets rerendered 5 times. I want to be able to write something lige this:

obj.suspendRefreshes()
for (i = 0; i < colCount; i++)
obj.setColumnWidth(w[i], indice[i])
obj.refresh()

Is there a way to stop automatic refreshes when I am changing several things so I can issue a final refresh when I am done?

Thanks,
Nicolas Frias
Friday, December 1, 2006
Alex,
Any ideas about this?
Nicolas Frias
Wednesday, January 3, 2007
There may be a better solution, but you could override refresh(), like this:

obj.orig_refresh = obj.refresh;
obj.refresh = function () {
    if (!obj.suspend) obj.orig_refresh();
}


And then modify your example:

obj.suspend = true;
for (i = 0; i < colCount; i++)
    obj.setColumnWidth(w[i], indice[i]);
obj.suspend = false;
obj.refresh();
CK
Wednesday, January 3, 2007
Thanks.
I added the following code so now I can even nest the calls to suspendRefresh. Clearly, they need to be paired.

obj.__suspendRefresh = 0;
obj.__orig_refresh = obj.refresh;

obj.refresh = function () {
if (this.__suspendRefresh == 0)
obj.__orig_refresh();
};

obj.suspendRefresh = function (suspend, skipRefresh) {
obj.__suspendRefresh += (suspend ? 1 : -1);
if (!skipRefresh) obj.refresh();
},
NF
Thursday, January 4, 2007

This topic is archived.


Back to support forum

Forum search