is an article page, for example, ten pages, the serial number is 1-10; 1 page stores a piece of data, but how do I sort it in the database after dragging it randomly??
The drag and drop modification content of each page is Save the database in real time,
I have two ideas now. One is to store everything locally, and wait until it submits all the pages to post, which saves trouble, but each page cannot be saved to the database in real time
The other way is to take the reordered article serial number to the database and modify the corresponding serial number, 12345; then move 3 to 12, which is 13245; but wouldn’t it be necessary to modify many pieces of data each time by dragging and sorting? If the user drags randomly, doesn't it mean he has to modify it many times each time? Looking for a better way
阿神2017-05-18 10:58:17
You can add an order redundant field to each piece of data, which is of float type. For the 1st, 2nd, 3rd, 4th, and 5th pieces of data, the order value when inserting each piece is 100, 200, 300, 400, 500. Now to move the 4th piece of data between 1 and 2, use 1 , the sum of the order values of 2 is divided by 2 as the new order value of the fourth piece of data, that is, the new order value of the fourth piece of moved data is 150. This way there is no need to modify the order values of other data.