On Dec 10, 11:19 am, "Sorrow" <jcbo...@yahoo.comwrote:
Quote:
I'm wondering if there is anything out there that discusses the above? I
need to be able to add and remove TDs and TRs to a table all the while
maintaining the overall layout. For example, if the table currently has one
row with 3 columns and the user wants to split the 1st column horizontally,
I need to ensure that the 2nd and 3rd columns have the 'rowspan="2"'
attribute. I can add/remove TDs and TRs easy enough. But I'm just not sure
the best way to keep track of the overall layout (ie, row and column spans)
as new ones are added/removed.
>
I'm wondering if anyone has any advice they can offer?
>
thnx,
Christoph
|
There are two approaches that I can think of offhand - I've
implemented the fist one in the past. The problem is that it is tough
to establish a correspondence between the cells in other rows/columns
and a given cell. This comes about because the HTML specifies
relationships of local cells (rowspan, colspan), and this can have
global consequences affecting the entire table.
You could conceptually assume that there is an underlying cell level
table where every cell in your cell level table points to the cell (or
cells) in the rendered table that cover it. AND every cell in the
rendered table points to the cell(s) in the underlying cell level
table that it covers. If you can build this table, then you can
easily identify related parts (columns, rows) in your original table.
Putting the underlying cell level table together is straightforward as
I recollect, but must be methodically done. Be careful to account for
situations like the first cell in all rows having a colspan greater
than 1. When I had to do detailed table work, this worked well for
me.
The second approach is to base this determination off geometry rather
than rowspan, colspan values. By identifying the top left, bottom
right corners of two cells, it's possible to determine whether they
overlap or not. This might be enough for your particular purposes.
Csaba Gabor from Vienna