KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Column width in DataTables #1562

Open vasim walikar opened this topic on on Aug 13, 2020 - 4 comments

vasim walikar commented on Aug 13, 2020

any one please help me how to give coloumn width for specific coloumn in datatables.

David Winterburn commented on Aug 14, 2020
DataTables::create(array(
    ...
    "options" => array(
        "columnDefs" => array(
            array(
                "width" => $yourColumnWidth, //in px, cm, or %
                "targets" => $yourColumnIndex
            )
        )
    )
));
vasim walikar commented on Aug 14, 2020

this is my code , but width is not reflecting in UI, could you please reiview the code

...........................continue code

David Winterburn commented on Aug 14, 2020

I forgot that we must set DataTables' autoWidth to false as well:

DataTables::create(array(
    ...
    "options" => array(
        'autoWidth' => false,
        "columnDefs" => array(
            array(
                "width" => $yourColumnWidth, //in px, cm, or %
                "targets" => $yourColumnIndex
            )
        )
    )
));

It should also be noticed that if your other columns' combine min widths are large, your preferred width column won't be able to be exactly 300px. You could reduce the number of columns to see the effect of width setting. Thanks!

vasim walikar commented on Aug 14, 2020

thank you

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None