Update order of the subsequent rows after deleting a row using server side script.

Update order of the subsequent rows after deleting a row using server side script.

Sohaib AhmadSohaib Ahmad Posts: 15Questions: 5Answers: 0

Currently we've a datatable that is getting populated from the php source. Table structure can be seen in the image below:

On deleting a row, I want the order column of the subsequent rows to be updated automatically in the database as well as the client side. So for example If I delete a row with order = 2, then the subsequent rows order should be automatically updated i.e order 3 should become 2, 4 become 3 and so on.

How can this be achieved on the server side ? Hope my question is understood clearly. Thanks

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    Are you using Editor? With that, you could do it through the API.

    Without, you would need to send an Ajax message to the server, and use code on there to update it.

    Colin

  • Sohaib AhmadSohaib Ahmad Posts: 15Questions: 5Answers: 0

    Yeah I'm doing it on Ajax request but this would be a large overhead If i delete a row with story odrder 100 and then update the subsequent order of the rows for a million records.

  • kthorngrenkthorngren Posts: 21,171Questions: 26Answers: 4,922

    Maybe you can explain more about what order is used for. Do you really need to update it in the DB if its going to cause large overhead?

    Do you just need it to be a dynamic index in the client? If so maybe this example will give you some ideas.

    Kevin

This discussion has been closed.