editor.create() Button Not Showing
editor.create() Button Not Showing
Hi
I am using DataTables and the Editor plugin on a semi-complex project . The thing I am stuck on at the moment is the following
Some of the values in the rows are dropdowns... I need to bind this when the "Create" Button is clicked. Normally these are pulled back via Ajax and and i am using the following code on the "render" method for that column
editor.field('dropdown').update(op['dropdown']);
with op
being an array in which I i store the dropdown values pulled back via ajax (there are several dropdown per row) , so this way I don't need to do an Ajax call for everyrow and can simply render the relevant dropdown
So if there is no data for the particular Datatable then the "render" method is never called and the code above never executed hence on the "Create" Popup the dropdown is empty.
My solution is this
buttons: [
{ extend: "create", editor: editor, action: function ( e, dt, node, config ) {
editor.field('dropdown').update(op['dropdown']);
editor.create();
}},
]
The above code works but strangely the actual "Create" button which submits the popup is no longer visible , I am unsure what the command is to show it or render it again.
Thanks in advance
This question has an accepted answers - jump to answer
Answers
Ok I got it working
editor.buttons('Save').create();
Explanation is here:
https://editor.datatables.net/reference/api/create()