Extend Datatable button for particular datatable.

Extend Datatable button for particular datatable.

core_javacore_java Posts: 13Questions: 4Answers: 0
edited November 2017 in Free community support

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

  • core_javacore_java Posts: 13Questions: 4Answers: 0

    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

  • core_javacore_java Posts: 13Questions: 4Answers: 0

    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

  • allanallan Posts: 63,464Questions: 1Answers: 10,466 Site admin

    I don't really understand I'm afraid - can you not just initialise the tables separately with the different configurations that each requires?

    Allan

  • core_javacore_java Posts: 13Questions: 4Answers: 0

    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.

  • allanallan Posts: 63,464Questions: 1Answers: 10,466 Site admin
    Answer ✓

    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

This discussion has been closed.