You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After updating the table's data with table.setData() the sort state is not consistent. I tried to fix this by calling the table.sortData(columnName,sortingDirection) function manually with the current sort-state-values found in table._sorting property after updating the table's data.
This works, but the sortingDirection is swapped after calling the table.sortData() function. Why does that happen?
table.sortData("userId","asc");//Sort by column userId in asc orderconsole.log(table._sorted)//Will print: {dir: 'desc', currentCol: 'userId'}
I also tried to found a workaround for this, by swapping the sorting direction values again... 😂 So this works for me now:
lettable=$('#tableContainer').tableSortable(tableOptions);table.setData(tableDataList,null);//Keep sorting state consistent (the table plugin does not care about this...)letsort=table._sorting;sort.currentCol=sort.currentCol=='' ? "userId" : sort.currentCol;sort.dir=sort.dir=='' ? "desc" : (sort.dir=="asc" ? "desc" : "asc");//<-- Yes, this looks ugly, but the sorting logic of this table-plugin is really crazy :Dtable.sortData(sort.currentCol,sort.dir);
The text was updated successfully, but these errors were encountered:
After updating the table's data with
table.setData()
the sort state is not consistent. I tried to fix this by calling thetable.sortData(columnName,sortingDirection)
function manually with the current sort-state-values found intable._sorting
property after updating the table's data.This works, but the sortingDirection is swapped after calling the
table.sortData()
function. Why does that happen?I also tried to found a workaround for this, by swapping the sorting direction values again... 😂 So this works for me now:
The text was updated successfully, but these errors were encountered: