:: Forum >>

obj.setColumnWidth hangs the grid and CPU processing goes to 99%

Hi Alex

Our Grid has 22 columns and 25 rows.When I call obj.setColumnWidth(100,1) the cpu processing goes to 99% and after full grid rendering the page remains locked for about 3 seconds.We are calling setColumnWidth on 22 columns because each columns has its own width.

We tried to study why this is occuring by studying the code of grid library.

AW.Grid.Controllers.Width =
{
onColumnWidthChanged: function(width, column)
{
try
{
if (this.element())
{
this.setTimeout(function()
{
this.raiseEvent("adjustScrollWidth");
this.raiseEvent("adjustScrollBars");

if (AW.ie && this.getScrollTemplate().element())
{
this.getScrollTemplate().element().className += ""
}
})
}

var w = (width - AW.dx) + "px", c = column;
var i, ss = document.styleSheets[document.styleSheets.length - 1];
var selector = "#" + this.getId() + " .aw-column-" + c;
var rules = AW.getRules(ss);

for (i = 0; i < rules.length; i++)
{
if (rules[i].selectorText == selector)
{
rules[i].style.width = w;
return
}
}

AW.addRule(ss, selector, "width:" + w)
}
catch (r)
{
}
}
The AW.Grid.Controllers.Width has setTimeout function which keeps the grid busy for 3-4 seconds .Removal of this function makes everything perfect but the changing the width of header does not keeps the body of grid in synch with header.

Its a bug that we have found in the Grid Library .

I have already posted the same affect in the following post :

http://www.activewidgets.com/javascript.forum.16043.2/memory-leaks-of-active-widgets.html

I have seen a post in which this bug has already been reported.

http://www.activewidgets.com/javascript.forum.12539.5/setcolumnwidth-issues.html

The above post suggest to fix it using css.But I am not sure how to do this .We dont require page refresh every time.

Can you provide a temporary fix for the defect?

Thanks
Vikramaditya Garg

Vikramaditya Garg
Thursday, September 7, 2006
Hi Alex

The Query is still unanswered.Please respond to the above amd please provide us with any workaround.

Thanks
Vikramaditya Garg
Vikramaditya Garg
Monday, September 11, 2006
Hi Alex

Your response will be appreciated.

Thanks
Vikramaditya Garg
Vikramaditya Garg
Wednesday, September 13, 2006
Yes, changing the width of all columns with setColumnWidths() might be very slow for a large grid. It will be much faster to remove grid from the page, update column widths and put the grid back:

var parent = grid.element().parentNode; // find parent DOM node
parent.innerHTML = ""; // remove the grid

for (var i=0; i<22; i++){
    grid.setColumnWidth(50, i); // update column widths
}

parent.innerHTML = grid; // put the grid back into the page


With the simple 22x25 grid the code above runs 0.8 sec (instead of 7.5 sec with the grid on page).
Alex (ActiveWidgets)
Wednesday, September 13, 2006

This topic is archived.


Back to support forum

Forum search