100% table width does not work

100% table width does not work

datatables7datatables7 Posts: 2Questions: 0Answers: 0
edited April 2014 in Bug reports
Hi,

I'm using the latest release and I cannot make the table header to be 100% and dynamically resized with the window. I found this example: http://datatables.net/release-datatables/examples/basic_init/flexible_width.html, which is quite useless because it doesn't give any indication as what was the html before the code was executed which is true for all the examples, btw. I added width attribute to the table with a value of 100%, I also added style with width set to 100%. I tried enabling/disabling bAutoWidth. I'm creating a table with the fnServerData, so the HTML is just this:

[code]




[/code]

and I add all the rows later. When I generate the columns that I pass as aoColumns to the constructor, I don't give width to any of the columns. Later, I want to specify the width of some of the columns but I would like to see a working example. I see that it is working if I don't pass sScrollY which I need so that the table is scrollable.

Example: http://fiddle.jshell.net/ZGyuA/1/

DataTables debugger: http://debug.datatables.net/ivuxix

How can I fix this issue?

Thanks.

Replies

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin
    Use DataTables 1.10 which has a built in call to fnAdjustColumnSizing: http://fiddle.jshell.net/ZGyuA/2/ . If you can't use 1.10, just call that function on window resize.

    Allan
  • datatables7datatables7 Posts: 2Questions: 0Answers: 0
    edited April 2014
    It is working. I would like to use the stable version for now, so I call fnAdjustColumnSizing from window resize. It is lagging quite a bit, but at least working. Thanks.

    EDIT:
    It doesn't seem to work when I have a big table that already needs horizontal scrolling.
    JSFiddle: http://jsfiddle.net/8d73V/
    DataTables debugger: http://debug.datatables.net/igomiq

    I also use TableTools but I removed that code from this example. The important things start from line number 67, the ones before just data generation.

    EDIT 2:
    My bad, I missed the sScrollX attribute.
  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin
    To be honest, I'd consider the 1.10 beta more stable than 1.9.4 (in some regards at least...). Its very nearly ready for release though - just a few more things to do :-)

    Allan
This discussion has been closed.