On Thu, Jul 3, 2008 at 6:10 AM, Eric H. Jung <[EMAIL PROTECTED]> wrote:
> ----- Original Message ---- > > From: Onno Ekker <[EMAIL PROTECTED]> > > To: [email protected] > > Sent: Wednesday, July 2, 2008 5:18:48 PM > > Subject: [Project_owners] Grids > > > > Hi, > > > > 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. > > > > nodelist = document.getElementsByTagName('row'); > > for (var i = 0; i < nodelist.length; i++) { > > var width1 = nodelist[i].firstChild.boxObject.width; dump(width1); > > var width2 = nodelist[i].lastChild.boxObject.width; dump(width2); > > } > > > > width1 and width2 are always 0. > > > > 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! */ > } Thanks! So (defaultView.)getComputedStyle is my friend. I'll try it out tonight, and see if I change the code to step over the columns instead of the rows. It may be cleaner, but will be more code, since I have to step over both the rows in cols1 and cols2 to calculate max-width and set it on both grids too. But than again: that may be the drawback of cleaner code and it`s well possible that it`s not only cleaner, but also more efficient... Onno
_______________________________________________ Project_owners mailing list [email protected] https://www.mozdev.org/mailman/listinfo/project_owners
