sWidth having no effect

sWidth having no effect

greenflashgreenflash Posts: 58Questions: 5Answers: 0
edited March 2011 in General
I've just started using DataTables and it's great - thank you. I have one problem though, which may well be to do with my not understanding how to configure DataTables - but I'm stumped, even after searching the forums.

I can't seem to get sWidth to do anything. I've got a scrolling table with pagination and a fixed first column and I want the first column width (indeed all column widths) to be constant so that when you sort the table, or page through it, the columns stay in the same place. I thought that applying sWidth would let me do this, but it does not seem to be applied at all. I'm setting it to 160px, but my tables just autosize to the width of the largest cell (which is less than 160px). Worse, the header does not resize as you page through the table so the header and body columns do not align, except on the first page. Here's my code:

[code]
var oTable = myTable.dataTable({"aoColumnDefs": [{"sWidth": "160px", "aTargets": [ 0 ]},
{"sType": "html", "aTargets": ["_all"]}
],
"iDisplayLength": 20,
"aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
"oColVis": {"aiExclude": [ 0 ]},
"oColReorder": {"iFixedColumns": 1},
"sDom": 'RC<"clear">lfrtip',
"sScrollX": "100%",
"sPaginationType": "full_numbers"
});

new FixedColumns(oTable);
[/code]

Any ideas?

Replies

  • greenflashgreenflash Posts: 58Questions: 5Answers: 0
    Well, I've achieved what I want to achieve for the moment by using CSS to control the width of the first column. But I still don't understand why sWidth didn't seem to do anything.

    Campbell
This discussion has been closed.