Hello, I’m trying to create a simple “arrow up” and “arrow down” button function to reorder rows in a table element and need some help with how I’m trying to do it or advice on a better way.
So each row is created with the entry of a new thing in the database, in the case of my app that thing is called a content block. On creation, each content block is given an index number and the table element is then sorted by index number. This then gives me my list of things on the app and the things which I would like to be able to reorder up or down in the list.
The first part of the workflow in which I’m moving a row is quite straight forward I think in that I simply make a change to the thing (content block) by doing a +1 or -1 on the index number as can be seen below:
For the second part of the workflow however, I need to make a change to either the row above the row being moved or the row below the row being moved, again I just need to make a change to the index number.
My problem is that I can’t work out the expression to use in order to select the row above or below the one which I am moving, for me to be able to change that records index number in the database.