Laravel-datatables: Control size of table, make responsive

Created on 12 Nov 2018  路  5Comments  路  Source: yajra/laravel-datatables

At the moment I wrap table inside .table-responsive

However, the size of column make the grid more than container, which add scroll on body.

Any idea how to fix this?

I saw an option in datatables for enable responsive, but can't find how to do that via PHP service class.

question

Most helpful comment

Thanks I got it.

I don't see too much change adding this option.

I added also autoWidth as false, this:

                ->parameters([
                    'responsive' => true,
                    'autoWidth' => false
                ])

Now the width is 100% always, but resizing window is not fully responsive.

I think that is required to add also the responsive css of datatable, as this example show:

https://www.datatables.net/extensions/rowreorder/examples/initialisation/responsive.html

I will try

All 5 comments

You need to have the responsive js plugins added. See https://datatables.net/reference/option/responsive for ref.

On server-side, just set the parameters 'responsive' => true.

Thanks for tips. Where to set that parameters? Considering that I am using Service class.

On the html function:

```php
->parameters([
'responsive' => true,
...
])

Thanks I got it.

I don't see too much change adding this option.

I added also autoWidth as false, this:

                ->parameters([
                    'responsive' => true,
                    'autoWidth' => false
                ])

Now the width is 100% always, but resizing window is not fully responsive.

I think that is required to add also the responsive css of datatable, as this example show:

https://www.datatables.net/extensions/rowreorder/examples/initialisation/responsive.html

I will try

Work fine adding css and js of responsive datatables:

<link href="//cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.min.css" rel="stylesheet">
<script src="//cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Yahav picture Yahav  路  16Comments

phainv picture phainv  路  16Comments

fanjavaid picture fanjavaid  路  32Comments

FaZeRs picture FaZeRs  路  18Comments

mantrax314 picture mantrax314  路  15Comments