DataTables applying zero width?
DataTables applying zero width?
Hi all,
Does anyone know why DT would apply weird width settings in the style attribute for a table?
My code looks like this:
[code]
<!--pasted directly from firebug -->
[/code]
Inspecting in firebug I see this:
[code]
<!--pasted directly from firebug -->
[/code]
What I end up with is an extremely narrow table. If I add my own width setting thus:
[code]
[/code]
I end up with this:
[code]
<!--pasted directly from firebug -->
[/code]
Baffling.
TIA
ruzz
Does anyone know why DT would apply weird width settings in the style attribute for a table?
My code looks like this:
[code]
<!--pasted directly from firebug -->
[/code]
Inspecting in firebug I see this:
[code]
<!--pasted directly from firebug -->
[/code]
What I end up with is an extremely narrow table. If I add my own width setting thus:
[code]
[/code]
I end up with this:
[code]
<!--pasted directly from firebug -->
[/code]
Baffling.
TIA
ruzz
This discussion has been closed.
Replies
Recall that the table has 11 THs, only 3 of which are visible. Checking in firebug, I see that DT is applying widths to my THs of 59px. That's 3 THs each saying width: 59px - I'm having to force the table back to 800px and then make sensible adjustments to the THs during fnInitComplete (which works).
Allan: something in your code is calculating column widths - right? (I mean, that 59 value came from somewhere and it's mentioned nowhere in my code). 11x59 = 649 (less than 800, but reasonable). However, if there's only 3 visible columns, why aren't we seeing 267px (800/3)? And what then decides the table's width should be 0px?
Of course, you could be setting the table width to zero THEN calculating the columns... I don't know.
Hope this is helping you help me, Allan.
ruzz
Curious... If the element containing the DataTable is display:none then this will happen (since the browser does not calculate the width of the table - if this is the case then you need to call fnAdjustColumnSizing, http://datatables.net/api#fnAdjustColumnSizing , when the element is made visible), but if it is visible on draw, then it shouldn't be drawing the width as 0.
What would be really useful here is if you could provide a link to an example which does this. Alternatively the HTML and JS which leads to this condition.
Allan
Firstly, an apology... I myself had suspected display:none. Whether this is the exact case I'm not sure, but the table *is* indeed embedded in a jQueryUI .dialog() - this at least I could have told you.
So... Allan... when you come to read the other thread "nTh.parentNode is null" - keep this in mind also ;) It's the same datatable.
Anyway, I now have more code in my fnInitComplete for this table than I would like... but it works.