Closed HenriqueSabino closed 7 months ago
You can't use auto columns with remote paginated data, it will reset the column layout on every page load breaking the sort
Ok. I got a work around for anyone in need
table.on('renderComplete', () =>
{
let columns = table.getColumns();
for (let column of columns) {
var sorters = table.getSorters();
const columnField = column.getField();
var sortingColumn = sorters.find(x => x.field === columnField);
console.log(sortingColumn)
if (sortingColumn) {
const dir = sortingColumn.dir === 'asc' ? 'ascending' : 'descending' ;
column.getElement().setAttribute('aria-sort', dir)
}
}
})
Describe the bug When the tabulator is configured with auto columns, after changing the page, the sort caret no longer represents the current sorting state of the table (running tabulator.getSorters() returns correct column).
Tabulator Info
Working Example
The JsFiddle reproducing the issue https://jsfiddle.net/v02qyorf/
To Reproduce A step by step guide to recreate the issue in your JS Fiddle or Codepen:
Expected behavior The sort caret of the column should stay the same because the new column loaded has same field name or alternatively there should be a way to set the column sort direction programatically
Screenshots Initial state Sorted column After page change
Desktop (please complete the following information):