Onno Ekker wrote:
Eric H. Jung wrote:
Onno wrote:
I have in my xul two grids with two columns each, both in a seperate
groupbox. I'd like both columns of both grids to have the same
width, but I can't seem to find the width of the current columns.
....
Is it possible at all to get and set these widths?
Is there another way to calculate the width of the label?
Or should I get the length of the label's values and then set width
to x
em?
Assuming your XUL is of this structure, try this:
<grid><columns id=cols1"><column/><column/></columns><rows><row ...
/></rows></grid>
<grid><columns id=cols2"><column/><column/></columns><rows><row ...
/></rows></grid>
/* Set widths of columns of 2nd grid to widths of columns of first
grid. Untested */
var cols1=document.getElementById("cols1"),
cols2=document.getElementById("cols2");
for (var i=0, sz=cols1.childNodes.length; i<sz; i++) {
var width =
document.defaultView.getComputedStyle(cols1.childNodes[i],
"width").width); /* might be a cleaner way */
dump("width of col " + i + " " + width);
cols2.childNodes[i].setAttribute("style", "width: " + width); /*
overwrites other styles if they exist! */
}
This works like a charm, now. Next problem is that resizing both
columns leaves my window too small, so that needs resizing too now. I
can probably find it's current size and add the differences to that
too in much the same way.
Looks like I was cheering too early.
I set the grids/rows/columns contents from the same script as I use to
calculate the width. The width I read is still 0 (sometimes)...
Maybe I should add an eventlistener to onDOMChange, like Jesper
suggested, to wait for the changes I made to bubble through? Or is there
a better way to deal with this timing problem?
Onno
_______________________________________________
Project_owners mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/project_owners