![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
Using the .cellIndex property of a TH element to find out which table column it is over can cause misleading results when the table has cells which have rowspans or colspans greater than 1. See example: http://www.javascripttoolbox.com/tem...cellindex.html (code pasted below for reference) This behaves according to specs and expectations, however the value of the cellIndex property becomes less useful when using it to determine which column to sort onclick, etc. I plan to write some code to calculate the "actual" column index of each cell in a <thead> of a table. But if anyone has already done this exercise, please do share so I can perhaps use my time working on something else ![]() |
#2
| |||
| |||
|
|
In particular, as my example shows, multiple cells can overlap the same "tile", and a given "tile" need not be overlapped by any cells at all! |
|
If you can guarantee that you will only query on the top row of the table |
#3
| |||
| |||
|
|
Csaba Gabor wrote: In particular, as my example shows, multiple cells can overlap the same "tile", and a given "tile" need not be overlapped by any cells at all! Overlapping of cells is, I believe, invalid. |
#4
| |||
| |||
|
|
Colspans are easy to taken into consideration. Rowspans are more difficult, and seem to require traversal through every row before and including the row of the cell for which you want to find the true cellIndex. |

#5
| |||
| |||
|
|
Matt Kruse said the following on 8/3/2006 4:43 PM: Csaba Gabor wrote: In particular, as my example shows, multiple cells can overlap the same "tile", and a given "tile" need not be overlapped by any cells at all! Overlapping of cells is, I believe, invalid. It is, and is only "honored" by IE by joining all the cells. |
#6
| |||
| |||
|
|
Csaba Gabor wrote: If you can guarantee that you will only query on the top row of the table Which, of course, isn't possible. If it were, then it would be trivial to find the true cellIndex value. Colspans are easy to taken into consideration. Rowspans are more difficult, and seem to require traversal through every row before and including the row of the cell for which you want to find the true cellIndex. |
#7
| |||
| |||
|
|
Matt Kruse wrote: Colspans are easy to taken into consideration. Rowspans are more difficult, and seem to require traversal through every row before and including the row of the cell for which you want to find the true cellIndex. Well, I've thrown together a really messy proof-of-concept at the same url: http://www.javascripttoolbox.com/tem...cellindex.html It appears to work, so I'm going to clean it up, optimize it, and add it to my table lib. If anyone sees any problem with the general logic, please do critique. I guarantee the "finished" version will be much prettier ![]() |

![]() |
| Thread Tools | |
| Display Modes | |
| |