Set column width for specific columns.

Set column width for specific columns.

GlyndwrGlyndwr Posts: 117Questions: 32Answers: 0

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: 20,585Questions: 26Answers: 4,823
    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: 117Questions: 32Answers: 0

    Hi Kevin,

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

    Kind regards,

    Glyn

  • kthorngrenkthorngren Posts: 20,585Questions: 26Answers: 4,823

    Looks like the column width is being set.

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

    Kevin

  • GlyndwrGlyndwr Posts: 117Questions: 32Answers: 0

    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.