:: Forum >>

obj.setRowHeaderWidth() do not work when reset.

I load data from XML, and can't get the obj.setRowHeaderWidth to set the width for the row headers. It works great if done before grid is written, but not if done when I recieve the XML-data. Any known fix?

This gets called in the _response:
function setRowHeaders(grid, xml) {
var rowTextXpath = "//@header";
var hNodes = xml.selectNodes(rowTextXpath);
var maxWidth = 0;

if (hNodes) {
for (i = 0; i < hNodes.length; i++) {
grid.setRowText(hNodes[i].text, i);
width = grid.getRowTemplate(i).element().firstChild.scrollWidth;
if (maxWidth < width) {
maxWidth = width;
}
}
     grid.setRowHeaderWidth(maxWidth);
grid.refresh();
alert("MaxWidth: " + maxWidth); // == 143, which seems correct.
}
}

MattiasF
Wednesday, January 19, 2005
Update: If I switch these lines
grid.setRowHeaderWidth(maxWidth);
grid.refresh();

The grid row headers do resize as expected (almost) but at the expense of the first column! That is, the row headers overwites the first column. How can I get the first column to move appropriatly?
MattiasF
Wednesday, January 19, 2005
When a new refresh comes by (like after a column sort) the row headers pop back to the default value. That is, my grid.setRowHeaderWidth(maxWidth); is totaly ignored :(
MattiasF
Wednesday, January 19, 2005
This width is alot better. It is the width of the row header instead of the first column.

(Remeber that this is done after the xml arrives in the _resonse method.)
function setRowHeaders(grid, xml) {
var rowTextXpath = "//@header";
var hNodes = xml.selectNodes(rowTextXpath);
var maxWidth = 0;
if (hNodes) {
for (i = 0; i < hNodes.length; i++) {
grid.setRowText(hNodes[i].text, i);
width = grid.getRowTemplate(i).getItemTemplate(i).element().scrollWidth;
if (maxWidth < width) {
maxWidth = width;
}
}
grid.refresh();
grid.setRowHeaderWidth(maxWidth);
     // If this refresh is done instead of the one upove, setRowHeaderWidth pops back to old value.
//grid.refresh();
}
MattiasF
Wednesday, January 19, 2005
From grid.js:
obj.setRowHeaderWidth = function(width){
        var layout = this.getTemplate("layout");
        layout.getContent("left").setStyle("width", width);
        layout.getContent("corner").setStyle("width", width);
        layout.getContent("top").setStyle("padding-left", width);
        layout.getContent("data").setStyle("padding-left", width);
    };


Those padding-left never kicks in when I use setRowHeaderWidth :(
I reset setRowHeaderWidth during an overloaded refresh to get around the reset, but still I get columns hidden behind the row headers.
MattiasF
Thursday, January 20, 2005
WooHoo I found it! Its a bug in the grid setRowHeaderWidth. It sould not refer to padding-left but paddingLeft!!!

layout.getContent("top").setStyle("paddingLeft", width);
        layout.getContent("data").setStyle("paddingLeft", width);

MattiasF
Thursday, January 20, 2005
Mind me, this measure on completly wrong strings:
width = grid.getRowTemplate(i).element().firstChild.scrollWidth;

use getTemplate("left/item", i) instead. But that do unfortunatly not seem to support the scrollWidth. I do not know how to measure the row header width at the moment.
MattiasF
Thursday, January 20, 2005

This topic is archived.


Back to support forum

Forum search