Table ordered by an ordinal. How to edit 1 ordinal and reorder the others to fit

Table ordered by an ordinal. How to edit 1 ordinal and reorder the others to fit

sun_storressun_storres Posts: 1Questions: 1Answers: 0
edited March 2021 in Free community support

So I have a table that has an ordinal order. It means that the first row is 1, the second is 2, etc...
Say I want to edit row 300 and change its ordinal to 3, I want to reorder the table so it shows the record 300 as the third row.
The ordinal would then be saved in the db (and fetched).

I see RowReorder does something similar, but dragging from the bottom to the top is tedious. Any solution using Editor?

I have tried this:

$('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
                enableSavePinsButton();
                editor.inline( this, 'overall_ranking_position' );
} );

Answers

  • allanallan Posts: 63,226Questions: 1Answers: 10,416 Site admin

    On the client-side, you would just change the value of the individual row as required and submit that.

    For this particular test, the interesting part is at the server-side. With Editor what you would need to do is use server-side events - you would use a preEdit event to find and update all database entries between the previous value for the row and the new value, so your sequence is still complete.

    The RowReorder example, while it doesn't show exactly that, it does show how server-side events can be used to retain the sequence on create and delete actions.

    The other option is to use a database trigger, if you are comfortable with them. That way all you do is write the value you want to the db, and it will sort the sequence out based on your trigger logic.

    Allan

This discussion has been closed.