Friday, April 14, 2017

how to make column width adjust automatically as per the data inside in Datatable

I am creating datatable as this :

var Master = $('#MasterGrid').DataTable( {
            "data": response,   
            "columns":columns,
            "scrollX": true,                            
            });
        $('#MasterGrid').show();

row design is distorted completely as the height of the row is increased because of column string length

my table rows height got irregular just because of this issue i am trying to make column width adjustable according to the dynamic data that is being filled in the column. i ve tried using :

 columnDefs: [
        { width: 200, targets: 0 }
    ],

and

scroller: {
    rowHeight: 30
}

by using scroller it is distorting my table style picture displaying the distortion in the datatable

I have tried using but nothing seems taking effect on the table

$('#masterGrid').column.adjust().draw();



via Rajat

Advertisement