Problems with sWidth

Problems with sWidth

earacheflearachefl Posts: 11Questions: 0Answers: 0
edited October 2011 in Bug reports
Not having any luck setting sWidth either using aoColumns or aoColumnDef. I've tried both setting individual column widths and all column widths - currently, my setting is:
[code]"aoColumns": [
{ "sWidth": "9%" },
{ "sWidth": "7%" },
{ "sWidth": "22%" },
{ "sWidth": "22%" },
{ "sWidth": "11%" },
{ "sWidth": "13%" },
{ "sWidth": "8%" },
{ "sWidth": "8%" }
],[/code]
Somehow, IE8 works best, in that setting sWidth anywhere doesn't totally break the column sizing; still, in IE 8, nothing much happens when you change column sizes. In Chrome and FF, the table sizing is totally broken as soon as I add any sWidth parameters, and the entire table becomes about 2/3 of its normal width. I'm only able to control sizing through css.

Replies

  • GregPGregP Posts: 500Questions: 10Answers: 0
    I don't use sWidth (I set my width in the HTML, old-school, in pixels), so I'm not 100% sure how the API works; however, I would be tempted to leave certain columns empty and let the math fall into place. For example, if I have a table of 4 columns, 2 narrow and 2 wide, I set the two narrow ones (they're more likely to need tweaking to fit content) to a particular width (say, 80px), which will evenly distribute the remaining two rows.

    Table widths have always been wacky, because they're the one case in which width settings are seen by the browser as a "guideline" instead of a firm setting, and the browser can in many cases override your settings with what it thinks the values SHOULD be.

    Back to sWidth: if the internal function related to sWidth allows for a total less than 100%, splitting the difference between any remaining columns, I would give that a try.
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    My (somewhat) educated guess is that the % you specify is just passed off to the browser via css/html, and allow the browser to do it's sizing magic. if you specify less than 100%, however your browser normally handles this, this will apply. and might not be the same across the different browsers.

    however, datatables does need to calculate widths in the header and tbody separately and force them to match up (not always successfully in my experience).
This discussion has been closed.