Fix sort order after column reorder on page reload

When columns are reordered via colReorder and the page is reloaded,
the saved sort state uses visual column indices. These were sent
directly as initial_order to the server, which interprets them as
original indices — causing the wrong column to be sorted.

Use the saved colReorder mapping to translate visual indices back to
original indices before sending initial_order in the _init request.
This commit is contained in:
Wieland Schopohl 2026-04-16 11:30:44 +02:00
parent a82d515034
commit 31e3049bdd

View file

@ -113,8 +113,16 @@ export default class extends Controller {
return null;
}
//The saved order index is visual (post-reorder). If colReorder state
//exists, map it back to the original column index so the server sorts
//the correct column. colReorder[visualIndex] == originalIndex.
let columnIndex = order[0];
if (saved_state.colReorder) {
columnIndex = saved_state.colReorder[columnIndex];
}
return {
column: order[0],
column: columnIndex,
dir: order[1]
}
});