Set column width for specific columns.

Set column width for specific columns.

GlyndwrGlyndwr Posts: 128Questions: 35Answers: 1

I am trying to set the width of a column. I have reviewed: https://datatables.net/reference/option/columns.width and then created this code: http://live.datatables.net/tipupiba/1/edit which is not setting the column width.

Kind regards,

Glyn

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,309Questions: 26Answers: 4,947
    Answer ✓

    Your example is giving this error in the browser's console.

    Uncaught TypeError: Cannot read property 'mData' of undefined

    The reason is you are using columns.data but have defined it for only one column. Changing the example to use columnDefs and columnDefs.targets removes the error and the Datatable now loads correctly.

    http://live.datatables.net/caciqeti/1

    Kevin

  • GlyndwrGlyndwr Posts: 128Questions: 35Answers: 1

    Hi Kevin,

    Thank you very much for your help. Unfortunately the column width is still not being set.

    Kind regards,

    Glyn

  • kthorngrenkthorngren Posts: 21,309Questions: 26Answers: 4,947

    Looks like the column width is being set.

    Try clicking the upward right arrow at the top of the Output tab.

    Kevin

  • GlyndwrGlyndwr Posts: 128Questions: 35Answers: 1

    Hi Kevin,

    Thanks for that. This works. I now have a more complex issue that I will create a new sample and post for.

    Kind regards,

    Glyn

This discussion has been closed.