Symfony 4 - How to use custom Datatables ajax to server
Symfony 4 - How to use custom Datatables ajax to server
Hi,
I am new using Datatables and we think it's a powerfull tool for our project, but I'm lost with it's implementation.
I need a Datatable on my page and sending/receiving data to/from my symfony 4 app.
As we have complex custom authorization to check any call to server, and also to check if the user can or can not edit any sended data (and in fact, read or write over a Symfony Entity), and also check the received data format, I don't know how to configure DataTables to send/get the data to a specific Symfony Controller so we can do all this process.
In fact, I need a custom send/receive data and sorry, I don't find any page explaining the sended/received format to read/modify/delete rows.
Or may be I am wrong and all this stuff can be configured for Symfony 4.
Coul you help me? Thanks.
This question has an accepted answers - jump to answer
Answers
Hi @esteban.olm,
This example here might help, it shows how the data being sent to a server can be manipulated, and this one here where the entire Ajax call is fiddled with.
I hope that helps, or at least gives you some ideas,
Cheers,
Colin
Hi,
Thanks, it worked.
I couldn't use the editor as I find the documentation complicated to understand or even to find, I could'nt find an basic example or how to edit a row, send the changed data to a the server, manage the received data by my own applicacation, and send the result (Ok, row, updated, Fail, yo don't have permissions, Fail, some column has an invalid value, etc...) back to the browser in appropiated format, so I had to do my own editor using symfony.
Best regards,
The parameters that Editor uses to send data to the server (after an edit, create, delete action) is documented here. The information on that page also details what it expects back in return (JSON data).
If you need to use an existing backend that already has the parameters setup, and you want to modify the data Editor sends (rather than modifying the server-side code to match what Editor sends by default) you can use
preSubmit
to modify the data object. You can also usepostSubmit
to modify the data coming back from the server to match what Editor expects.Alternatively, you could use
ajax
as a function to have complete control over the data submitted and returned, although you will still need to do the transform from what Editor sends and what it expects.Regards,
Allan