NullRefExcep / yii2-datatables

Yii2 Widget for DataTables jQuery plug-in
http://www.datatables.net/
MIT License
72 stars 46 forks source link

Can I use Buttons (print, excel, etc.)? #63

Closed ledniczkyrobert closed 3 years ago

ledniczkyrobert commented 4 years ago

Adding
'dom' => 'Bfrtip', 'buttons' => [ 'print' ],

not working

ZAYEC77 commented 4 years ago

Hey đź‘‹ @ledniczkyrobert Could you give a full example?

ledniczkyrobert commented 4 years ago

Yes, a working example in a view (except for the print button):

`<?= \nullref\datatable\DataTable::widget([

'data' => $dataprovider->getModels(),
'tableOptions' => [
    'class' => 'display cell-border',
],
'paging' => false,
'dom' => 'Bfrtip',
'buttons' => [
  ['extend' => 'print'
  ]
],
'columns' => [
    [
        'data' => 'id',
        'title' => 'ID'
    ],
    [
        'data' => 'th_site',
        'title' => 'TH',      
    ],
    [
        'data' => 'loc',
        'title' => 'Location',      
    ],
],
'language'=> [
    'info' => 'Találatok: _START_ - _END_ Összesen: _TOTAL_',
    'infoFiltered' => '(_MAX_ összes rekord közül szűrve)',
    'infoEmpty' => 'Nincs találat',
    'search' => 'Szűrés'
]

]) ?>`

What i can see in vendor/bower/datatables/media/js folder, that ther is no files like dataTables.buttons.js and buttons.print.js, these are requirements for the print button to work according to datatables.net.

ZAYEC77 commented 4 years ago

Looks like custom stuff. I guess you should create a new AssetBundle that adds files that you need. Feel free to create PR for this repo if you wish.

One more option is to override the default asset bundle. Please check the readme section about it: https://github.com/NullRefExcep/yii2-datatables#custom-assets

ZAYEC77 commented 3 years ago

🤷‍♂️