how to modify datatable buttons settings after the datatable initialisation
how to modify datatable buttons settings after the datatable initialisation
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
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 thenbuttons()
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
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!