How to split comma joined list ind idSrc =_id_

How to split comma joined list ind idSrc =_id_

Muhammad IzzatMuhammad Izzat Posts: 22Questions: 10Answers: 0

Greeting everyone, Based from this reference

https://editor.datatables.net/reference/option/ajax

I want to edit and delete multiple row in my table using ajax and REST API but right now its not working because of an error in the URL source, the URL will look like this

E.g: if i select row 1,3, and 5 the URL will become

url : '/tableRowdata/1,3,5'

How can I split the comma joined list so that i can use a for loop to to execute the URL 1 by 1 for each selected row?

Any help is much appreciated thank you very much

Replies

  • allanallan Posts: 61,972Questions: 1Answers: 10,161 Site admin

    The most efficient way would be to modify your routing at the server side to accept that form of data and simply have it loop over the ids given. That way there would be only one Ajax request.

    If you must split it up, you are going to incur network latency for every item edited. You would need to override the default Ajax command via ajax, replacing it with your own, which would split the URL as needed and submit the items to the server, each in turn, and the combine the results to feedback to Editor. There isn't a built in option for doing that I'm afraid, since, as I say, it if far more efficient for the server to do it.

    Allan

  • Muhammad IzzatMuhammad Izzat Posts: 22Questions: 10Answers: 0

    Thank you for your reply Allan, this helps

This discussion has been closed.