Not able to change datatable td column width
Not able to change datatable td column width
Maddy
Posts: 24Questions: 0Answers: 0
Hi, I have the following datatable:
$(function() {
var dataTableColumns = [
{ "sType": "numeric" },
null, null, null, null, null,
null, null, null, null, null, { "sType": "date-dayofweek" },
null, null, null, null, null, null, { "sType": "date-dayofweek" },
null, null, null, null, null,
null, null, null, null, null,
null, null, null, null,
null, null, null, null,
null, null, null, null,
null, { "sType": "date" }, null
];
oTable = $('#example').dataTable({
"bPaginate" : true,
"aaSorting": [ [0,'asc'] ],
"aoColumns" : dataTableColumns,
"oLanguage": {
"sLengthMenu": 'Show '+
'10<\/option>'+
'25<\/option>'+
'50<\/option>'+
'100<\/option>'+
'All<\/option>'+
'<\/select> records'
},
"iDisplayLength": -1,
});
});
Few columns in the above datatable contain text data and I want to specify width option for those columns. I tried various options bAutoWidth, sWidth, td width, css style, fnAdjustColumnSizing, but nothing seems to work.. I dont know what's going wrong.. Please help!!
$(function() {
var dataTableColumns = [
{ "sType": "numeric" },
null, null, null, null, null,
null, null, null, null, null, { "sType": "date-dayofweek" },
null, null, null, null, null, null, { "sType": "date-dayofweek" },
null, null, null, null, null,
null, null, null, null, null,
null, null, null, null,
null, null, null, null,
null, null, null, null,
null, { "sType": "date" }, null
];
oTable = $('#example').dataTable({
"bPaginate" : true,
"aaSorting": [ [0,'asc'] ],
"aoColumns" : dataTableColumns,
"oLanguage": {
"sLengthMenu": 'Show '+
'10<\/option>'+
'25<\/option>'+
'50<\/option>'+
'100<\/option>'+
'All<\/option>'+
'<\/select> records'
},
"iDisplayLength": -1,
});
});
Few columns in the above datatable contain text data and I want to specify width option for those columns. I tried various options bAutoWidth, sWidth, td width, css style, fnAdjustColumnSizing, but nothing seems to work.. I dont know what's going wrong.. Please help!!
This discussion has been closed.
Replies
Also, an example would be really useful to see what you are trying to achieve and where it is going wrong :-)
Allan
Here's the working example of my datatable-
oTable = $('#example').dataTable({
"aaSorting": [ [0,'asc'] ],
"bAutoWidth" : false,
"aoColumns" : dataTableColumns,
"oLanguage": {
"sLengthMenu": 'Show '+
'10<\/option>'+
'25<\/option>'+
'50<\/option>'+
'100<\/option>'+
'All<\/option>'+
'<\/select> records'
},
"iDisplayLength": -1,
});
dataTableColumns contain table headers and sWidth option for few columns.
HTML code -
Please let me know if you have any other inputs. Thanks much :)