Sunday, September 18, 2022

Word wrap column data in Javascript datatable

Set autoWidth to false and define your prefered column width's :


var table = $('#example').DataTable({

    autoWidth: false,

    columns : [

        { width : '50px' },

        { width : '50px' },

        { width : '50px' },

        { width : '50px' },        

        { width : '50px' },

        { width : '50px' }        

    ] 

});

then, most important - add this CSS :


table.dataTable tbody td {

    word-break: break-word;

    vertical-align: top;

}


http://jsfiddle.net/qh63k1sg/ 

No comments:

Post a Comment