Set and load language file for all created datatables
Set and load language file for all created datatables
brian82
Posts: 7Questions: 3Answers: 0
Hi
I have a lot of datatables on my website like 30 or more, and for each of them i need to load language file in options when i define datatable instance.
Is it possible to load same language and options like those below just once, for example: Datatable({ //options }); , so this applies to each datatable created.
dom: 'Bfrtip',
buttons: [
{
extend: 'copy',
text: '<i class="fa-sharp fa-solid fa-copy"></i>',
},
{
extend: 'excel',
text: '<i class="fa-sharp fa-solid fa-file-excel"></i>',
},
{
extend: 'pdf',
text: '<i class="fa-sharp fa-solid fa-file-pdf"></i>',
},
{
extend: 'print',
text: '<i class="fa-sharp fa-solid fa-print"></i>',
exportOptions: {
columns: ':visible',
}
},
{
extend: 'colvis',
text: 'Show'
},
'pageLength'
],
lengthMenu: [ 5, 10, 25, 50, 100 ],
pageLength: 25,
select: false,
language: {
url: '//cdn.datatables.net/plug-ins/1.13.1/i18n/hr.json'
}
This question has an accepted answers - jump to answer
Answers
You can set default options as described here.
Kevin