Column width

Column width

David7David7 Posts: 6Questions: 3Answers: 0
edited March 2022 in DataTables

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.


  • colincolin Posts: 15,202Questions: 1Answers: 2,592

    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.



Sign In or Register to comment.