Closed artembatura closed 6 years ago
Try extending the text property. See https://datatables.net/extensions/buttons/config for details.
{
"extend": 'copy',
"text":'<i class="fa fa-copy"></i> Copy',
"className": 'btn-outline-primary btn-sm'
},
{
"extend": 'excel',
"text":'<i class="fa fa-file-excel-o"></i> Excel',
"className": 'btn-outline-primary btn-sm'
},
{
"extend": 'pdf',
"text":'<i class="fa fa-file-pdf-o"></i> PDF',
"className": 'btn-outline-primary btn-sm'
},
I call scripts inside my blade view file, if you do the same than simply create language files for each language called /resources/lang/en/datatablebuttons.php and add entries
'copy' => 'Copy',
'excel' => 'Excel',
'pfd' => 'PDF',
'print' => 'Print'
/resources/lang/de/datatablebuttons.php
'copy' => 'Kopieren',
'excel' => 'übertreffen',
'pfd' => 'PDF',
'print' => 'Drucken',
You could try:
{
"extend": 'copy',
"text":'<i class="fa fa-copy"></i> {{ __('datatablebuttons.copy') }}',
"className": 'btn-outline-primary btn-sm'
},
{
"extend": 'excel',
"text":'<i class="fa fa-file-excel-o"></i> {{ __('datatablebuttons.excel') }}',
"className": 'btn-outline-primary btn-sm'
},
{
"extend": 'pdf',
"text":'<i class="fa fa-file-pdf-o"></i> {{ __('datatablebuttons.pdf') }}',
"className": 'btn-outline-primary btn-sm'
},
@fishmad Thank you for idea 👍
It maybe useful for someone. I use InfyOm Laravel Generator and write in resources/views/layouts/datatables_js.blade.php
this code:
(function ($, DataTable) {
"use strict";
DataTable.ext.buttons.create.text = function (dt) {
return '<i class="fa fa-plus"></i> ' + dt.i18n('buttons.create', '{{ __('datatables_buttons.create') }}');
};
DataTable.ext.buttons.export.text = function (dt) {
return '<i class="fa fa-download"></i> ' + dt.i18n('buttons.export', '{{ __('datatables_buttons.export') }}');
};
DataTable.ext.buttons.print.text = function (dt) {
return '<i class="fa fa-print"></i> ' + dt.i18n('buttons.print', '{{ __('datatables_buttons.print') }}');
};
DataTable.ext.buttons.reset.text = function (dt) {
return '<i class="fa fa-undo"></i> ' + dt.i18n('buttons.reset', '{{ __('datatables_buttons.reset') }}');
};
DataTable.ext.buttons.reload.text = function (dt) {
return '<i class="fa fa-refresh"></i> ' + dt.i18n('buttons.reload', '{{ __('datatables_buttons.reload') }}');
};
})(jQuery, jQuery.fn.dataTable);
In resources/lang/ru/datatables_buttons.php
:
return [
'create' => 'Создать',
'export' => 'Экспорт',
'print' => 'Печать',
'reset' => 'Сбросить',
'reload' => 'Обновить'
];
And in resources/lang/en/datatables_buttons.php
:
return [
'create' => 'Create',
'export' => 'Export',
'print' => 'Print',
'reset' => 'Reset',
'reload' => 'Refresh'
];
Then i change locale
in config/app.php
to the desired language(don't forget about fallback_locale
)
how to hide the create button? when I try to hide the create button it doesn't show my table
How to change this buttons label?(for translate)