Skip to content

Commit 35262a2

Browse files
committed
Adds buttons to all data tables that allow export via excel and CSV. Need to find a way to allow translations
1 parent 851055b commit 35262a2

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

assets/controllers/elements/datatables/datatables_controller.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,22 @@ export default class extends Controller {
122122
header: $(window).width() >= 768, //Only enable fixedHeaders on devices with big screen. Fixes scrolling issues on smartphones.
123123
headerOffset: $("#navbar").outerHeight()
124124
},
125-
buttons: [{
126-
"extend": 'colvis',
127-
'className': 'mr-2 btn-outline-secondary',
128-
'columns': ':not(.no-colvis)',
129-
"text": "<i class='fa fa-cog'></i>"
130-
}],
125+
buttons: [
126+
{
127+
"extend": 'colvis',
128+
'className': 'mr-2 btn-outline-secondary',
129+
'columns': ':not(.no-colvis)',
130+
"text": "<i class='fa fa-cog'></i>"
131+
},
132+
{
133+
text: 'CSV',
134+
action: $.fn.initDataTables.exportBtnAction('csv', settings),
135+
},
136+
{
137+
text: 'Excel',
138+
action: $.fn.initDataTables.exportBtnAction('excel', settings),
139+
}
140+
],
131141

132142

133143
rowCallback: this._rowCallback.bind(this),

0 commit comments

Comments
 (0)