Question about customizing Editor ajax object

Question about customizing Editor ajax object

chillychilly Posts: 7Questions: 4Answers: 0

Hello, I currently am using Datatables Editor API through my company's license (just to say I'm a valid user, this is just my personal account).

Our current project controls database operations via REST API calls. I've been following this example here to integrate Datatables with our custom REST calls: https://editor.datatables.net/examples/advanced/REST.html

One thing I was looking to work around: instead of passing the data to an external php file as in this example, would it be possible to process the data and do a REST call via a JavaScript callback? How would you access the row data when doing the ajax calls for create/delete/edit?

Thanks for any help you can offer

Answers

  • allanallan Posts: 61,934Questions: 1Answers: 10,155 Site admin

    would it be possible to process the data and do a REST call via a JavaScript callback?

    Certainly - the ajax option can be given as a function which allows complete control over where the data is sent and what you do with it. Equally, create, edit and remove options can be specified for the ajax option, each of which inherits the same list of options as the parent - i.e. you could use ajax.create as a function and ajax.edit as a string URL. Might be a little mad that last option - but it is possible :-)

    You might also be interested in this example which shows ajax being used as a function.

    Regards,
    Allan

This discussion has been closed.