Colspan in a non-header row cell
Colspan in a non-header row cell
ProudDT_User
Posts: 1Questions: 0Answers: 0
Greetings,
I have really been enjoying the new rowspan/colspan functionality of 1.8b.
However, I am having some issues with non-header row cells that try to take advantage of the header colspan.
What I would like is to have certain headers have colspan=2 so that I can have cell borders dividing a cell. Version 1 of my example below demostrates what I THOUGHT would work..
Version 2 is my workaround, but I am having a hell of a time trying to have the cell borders connect (vertical to top/bottom cell border).
[code]
FIXED COLUMN
Top1
Top2
Top3
Bottom1
Bottom2
Bottom3
<!---- How I thought it would work (Version 1)--->
Row Cell One
$100
$180
15*12
$180
1
2
<!-- A workaround, but I can't seem to the vertical border lines connect when
I have cell borders (Version 2)-->
Row 2
ELEMENT1
ELEMENT2
$180
15*12
15*12
15*12
[/code]
Is this something that is supported with DataTables or am I asking too much?
Looking forward to your response.
I have really been enjoying the new rowspan/colspan functionality of 1.8b.
However, I am having some issues with non-header row cells that try to take advantage of the header colspan.
What I would like is to have certain headers have colspan=2 so that I can have cell borders dividing a cell. Version 1 of my example below demostrates what I THOUGHT would work..
Version 2 is my workaround, but I am having a hell of a time trying to have the cell borders connect (vertical to top/bottom cell border).
[code]
FIXED COLUMN
Top1
Top2
Top3
Bottom1
Bottom2
Bottom3
<!---- How I thought it would work (Version 1)--->
Row Cell One
$100
$180
15*12
$180
1
2
<!-- A workaround, but I can't seem to the vertical border lines connect when
I have cell borders (Version 2)-->
Row 2
ELEMENT1
ELEMENT2
$180
15*12
15*12
15*12
[/code]
Is this something that is supported with DataTables or am I asking too much?
Looking forward to your response.
This discussion has been closed.
Replies
The way DataTables works is that it requires a unique TH element for each column in the table. So while you can do some fairly cool stuff with the colspan / rowspan in the header, it doesn't allow for what you've got at the moment I'm afraid. In the header you only have 4 columns from DataTables' perspective (the first rowspan, and then three columns with a colspan of 2 each), but your've got 7 (or 6 in the second example) data columns. The reason that a unique TH is required for each column is for sorting (and it makes it a _lot_ easier to track what data should go where).
There is one option however which suggests itself - what you could do is have a unique TH for each column in another TR in the THEAD - but when the table is initialised, just set it to height: 0. Of course, sorting might be a bit odd since you don't have control over each column (as a user) and you would need to add the sort handlers to the TH elements you want (using fnSort).
Hope this helps,
Allan