Click to See Complete Forum and Search --> : Table alignment problem with result set


karlmcauley
09-08-2004, 05:08 AM
I have two tables: one table forms the header columns
and the other table is in an iframe returning the results of an
sql query. The query works fien and returns the appropriate data
but the rendering of the columns in the top table does notmatch
those in the iframe table, even though they are supposed to be the same width!!

The iframe table has a scroll bar and the data returned sizes each column cell
dependant on the amount of data returned regardless if i stipulate a set width!!

As you can imagine this is visually poor as the table columns are not correct for both tables!!

Has anyone idea of what i could do? Could i use javascript to set the width of the header columns when the iframe columns load and i know what width they are?

Sample header table and iframe table attached.

Many thanks in advance.

Cheers

HaganeNoKokoro
09-08-2004, 08:07 AM
if you assign all the tds in the header table and (at least) the first row of the data table id attributes, it can be done.

You would, in the document that goes in the iframe, create a function for the onload event handler that resizes the columns.

Below is the quickest example I could cook up. In my example, I gave all the table header columns ids like "th1" and all the data columns ids like "td1". mytable.html is intended to be the content document with your resultset, so play around with a few columns and see how it shapes up. The file you should actully view in a webbrowser is tabletest.html.

P.S. I tried this out in IE6 and Netscape7, which are the only browsers I have. No clue if it works well in others.

Also, if someone else can come up with a better way, fell free to trash mine; I know it's not a particularly good solution. Something non-javascript, as many will doubtless point out, would be nice, but I can't figure out a way.

karlmcauley
09-09-2004, 07:00 AM
Thanks for your reply.

On the whole it seems to work, but only if i dont have any scroll bars present in the iframe table page. More often than not the returned sql query will be long enough to go off the page and as such needs to remain scrollable!! and if its scrollable the column aligment is slightly out of zinc with its header.!!!

Any ideas?

Anyway i can counteract the scroll bar yet not impinge upon the width of any other column??

Cheers