How to set the functions for "Edit" or "Delete" buttons above the dataTable?
How to set the functions for "Edit" or "Delete" buttons above the dataTable?
ismaelw
Posts: 2Questions: 1Answers: 0
My main problem is, that I don't know, how i tell the dataTable.Editor function what to do when the "Edit" or the "Delete" button is pressed.
Than I should know how my php Script should look like to update or remove a row in my MySQL Database.
This discussion has been closed.
Answers
Hi. Sorry if the answer sounds a bit basic, but just follow through the simple Editor example.
http://editor.datatables.net/examples/simple/simple.html
The "editor_edit" and "editor_remove" buttons are preset buttons that refer to the editor function given immediately after (eg. sExtends: "editor_create", editor: editor" refers to the "editor = new $.fn.dataTable.Editor()" instance. If you want to create another editor instance, call it "editor2" (or whatever) in both the editor instance and the button reference.
If you want to customise what the editor function does, try out this example for customised buttons:
http://editor.datatables.net/examples/api/triggerButton.html
Happy Days,
nige
Hi Nige,
Thank you for your answer. My problem is now, that I don't know how to proceed after the "->process( $_POST )
->json();" line in the server side script. From there I should go on with updating an entry of my database.
And what is the script like for deleting an entry?
I'm not that new in php but very new with this whole DataTable/Editor thing.
Thanks for your help
Ismael
Hi Ismael,
We've talked about this by e-mail a little bit as well. Good to hear that you have been able to make a bit of progress here.
The
Editor
PHP class will handle get, insert, update and delete actions automatically. You do not need to use different scripts (you can if you want, but you don't need to). Have a look at the Editor examples - almost all use a single script.Allan