how to modify datatable buttons settings after the datatable initialisation

how to modify datatable buttons settings after the datatable initialisation

Fatou_vaFatou_va Posts: 8Questions: 3Answers: 0

how to modify datatable buttons settings after the datatable initialisation for settings more options like formTitle, formButtons, ....
I have create my datatable with the buttons for editor.

here my datatable initialization :

$('#myTable').DataTable({
                bDestroy: true,  //supprime la table si elle existe déjà et la réinitialise avec la nouvelle config defini ci-après
                ajax: {  
                    type: 'GET',
                    url: urlDataSource,
                    dataSrc: '' 
                },
                select: true, 
                dom: 'Bfrtip',
                buttons: [ 
                        { extend: "create", editor: myEditor'},
                        { extend: "edit", editor: myEditor},
                        { extend: "remove", editor: myEditor}
                columns: columns
            });

After this, I would like to add a text, formtitle, and formButtons options to each button, but I don't known how to do this.
I have try to delete buttons (by use table.button(indexButton).remove(); ) then recreate them whith the new settings (table.button().add(index, newOptionsButton); ), this create buttons but when I click on them, I got this error

Uncaught TypeError: Cannot read property 'create' of null
    at r.action (dataTables.editor.min.js:106)
    at r (dataTables.buttons.min.js:13)
    at HTMLAnchorElement.<anonymous> (dataTables.buttons.min.js:13)
    at HTMLAnchorElement.dispatch (jquery.js:3)
    at HTMLAnchorElement.r.handle (jquery.js:3)

How can i modify the buttons settings?. Does anyone have an idea? Thanks .
Sorry for my english!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Answer ✓

    If you have to do it after initialisation rather than at initialisation time, then I would recommend you use the Editor API directly. Use initEdit, initCreate etc and then buttons() to define the buttons, title() to set the title, etc.

    One thing you need to remember is that the table buttons (create, edit and remove as you have above) are not the same as the form buttons in the Editor form.

    Allan

  • Fatou_vaFatou_va Posts: 8Questions: 3Answers: 0

    Hi Allan,

    I hoped to find an option to do it directly without having to cross by event. But well .... I am going to make with

    One thing you need to remember is that the table buttons (create, edit and remove as you have above) are not the same as the form buttons in the Editor form.
    Yes I make the difference.

    Thank you Allan!

This discussion has been closed.