sWidth having no effect
sWidth having no effect
greenflash
Posts: 58Questions: 5Answers: 0
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?
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?
This discussion has been closed.
Replies
Campbell