How to use dDom and Buttons at the same time
How to use dDom and Buttons at the same time
u20241229
Posts: 6Questions: 3Answers: 0
Hi,
This example includes copy and column visibility options:
https://live.datatables.net/guvuzopo/1/edit
I have included some buttons via this code:
$(document).ready(function () {
var table = $('#example').DataTable({
order: [],
bLengthChange: false,
responsive: true,
colReorder: true,
pageLength: 365,
// sDom: '<"top"lfip>rt<"bottom"ip<"clear">',
mark: true,
layout: {
topStart: {
buttons: ['copy', 'csv', 'excel','colvis']
}
}
});
});
However - as per this 2nd example - I'd like to use sDom to change the layout as follows:
https://live.datatables.net/bovedoxo/1/edit
Using this code:
$(document).ready(function () {
var table = $('#example').DataTable({
order: [],
bLengthChange: false,
responsive: true,
colReorder: true,
pageLength: 365,
sDom: '<"top"lfip>rt<"bottom"ip<"clear">',
mark: true,
layout: {
topStart: {
buttons: ['copy', 'csv', 'excel','colvis']
}
}
});
});
However - using sDom then removes the buttons.
I can't work out what I need to include in the sDom line to ensure that the buttons also appear?
Thanks
Answers
Sorry, I found out how to do it by using
layoutand the grid:https://live.datatables.net/cehunufu/1/edit
Yup - use
layoutfor any new code.domis still supported, but is really isn't fun to use.layoutis a lot easier to useAllan