Column width
Column width
![David7](https://secure.gravatar.com/avatar/1b09284ea024e665f2db93f537ca6085/?default=https%3A%2F%2Fvanillicon.com%2F1b09284ea024e665f2db93f537ca6085_200.png&rating=g&size=120)
Hello,
Just very simple question. How can I set colunm widht? Such simple task should be simple, but I didn't find any info.
var dataTable = $("#dataTable").removeAttr('width').DataTable({
data: data,
autoWidth: false,
columns: [
{ data: 'StatusString', name: 'StatusString', title: 'Stav', width: "50px" },
{ data: 'Id', name: 'Id', title: 'Id', width: "50px" },
{ data: 'ProviderName', name: 'ProviderName', title: 'Poskytovatel', width: "50px" },
],
dom: 'Bfrtip',
columnDefs: [
// Sector name.
{
targets: 2,
render: function ( data, type, full, meta ) {
return `<div style='white-space: normal; width: 200px;'>${data}</div>`; }
},
});
Thank you
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
https://datatables.net/reference/option/columns.width
Yep, that's the option, as @rf1234 mentioned, but I see that you're using that already in your config. If it's not working for you, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin