Extend Datatable button for particular datatable.
Extend Datatable button for particular datatable.
I have two or more datatable on Single page.
I want to extent functionality of buttons for one datatable and rest datatable buttons should work as same as.
I added class to check which table need extending buttons.
One datatable - Client side export and another for serverside export so it will not break code when client side export not working.
I had used as below:
on init.dt event
const api = new $.fn.dataTable.Api(settings);
api.buttons('.buttons-csv').action(function (e, dt, button, config) {
window.location = _buildUrl(dt, 'csv');
}).text(function (dt) {
return dt.i18n('buttons.csv', 'CSV');
});
Is there any good way or easy way to extend also class
Pl. need helpful.
This question has an accepted answers - jump to answer
Answers
I had used as below:
on init.dt event
const api = new $.fn.dataTable.Api(settings);
api.buttons('.buttons-csv').action(function (e, dt, button, config) {
window.location = _buildUrl(dt, 'csv');
}).text(function (dt) {
return dt.i18n('buttons.csv', 'CSV');
});
Is there any good way or easy way to extend also class
I have two or more datatable on Single page.
I want to extent functionality of buttons for one datatable and rest datatable buttons should work as same as.
I added class to check which table need extending buttons.
One datatable - Client side export and another for serverside export so it will not break code when client side export not working.
I had used as below:
on init.dt event
const api = new $.fn.dataTable.Api(settings);
api.buttons('.buttons-csv').action(function (e, dt, button, config) {
window.location = _buildUrl(dt, 'csv');
}).text(function (dt) {
return dt.i18n('buttons.csv', 'CSV');
});
Is there any good way or easy way to extend also class
I don't really understand I'm afraid - can you not just initialise the tables separately with the different configurations that each requires?
Allan
I am using laravel yajra datatable using service. Which generate serverside export.
Now I have two table using laravel yajra service with server side export and another for client side htmlcsv button.
So how can I extend button based on only paticular datatable without affecting other datatables button's functionality.
I still don't understand why you can't just initialise the tables differently? Use a different button definition for the one which needs the server-side export (I didn't know laravel yajra did that!).
Allan