question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Way to stop b-table from re-sorting immediately on data update?

See original GitHub issue

Describe the bug question

I’m using the b-table component and its built-in sorting functionality.

In each row of my data, I’m using slots to insert a checkbox, which the user can click to select or deselect the row and associated data (I chose this over the native “select row” functionality for reasons). I’ve added the ability to sort by this column using a custom compare function bound to the :sort-compare prop, allowing the table to bring all the checked rows to the top (or bottom). The problem is that if the user checks/ unchecks a row while sorted this way, the row instantly gets re-sorted, and jumps elsewhere in the table, which is very undesirable.

My question is this: Is there a way to prevent instant re-sorting, and only re-sort when the user changes the sort (when sort-changed fires)? Or do I need to implement manual sorting to make this happen?

Versions

Libraries:

  • BootstrapVue: 2.11.0
  • Bootstrap: 4.4.1
  • Vue: 2.6.11

Environment:

  • Device: PC
  • OS: Windows 10
  • Browser: Chrome
  • Version: 85.0.4183.102

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

5reactions
zcoop98commented, Sep 25, 2020

Feel like it’s worth mentioning that by now I just went ahead and disabled sorting with the no-local-sorting prop, and pulled the custom sort routine that I already wrote for sort-compare into my own sort function. I tied this to the @sort-changed event, and got the desired effect: sorting only happens when you click the header, and doesn’t immediately change with edited data.

It would still be nice to be able to set a boolean prop for this behavior however, as I personally didn’t at all expect the immediate-re-sort behavior that’s default. In my experience, most tables I’ve interacted with don’t seem to do that; immediate re-sorting here felt jarring and unexpected.

0reactions
rizencommented, Mar 19, 2021

Thank you to @zcoop98 for the idea on how to fix this, and I agree that it should just be a local option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BootStrap Table-How to stop b-table from re-sorting ...
After sorting the b-table, if the data in the table is modified then the table will resort automatically. How to stop b-table from...
Read more >
How to prevent a column in a table from sorting
Rather than adding a new column for the next week, add the information to the bottom of the table. Of course, that requires...
Read more >
Solved: Disable sorting in Table - Microsoft Power BI Community
Solved: Hi there! Is there a way of making a table in Power BI "static" or basically disable sorting? Thank you in advance!...
Read more >
How to update table after sorting? - JMP User Community
Yo can also create a new data table that is either invisible, or private, which will keep the new data table from being...
Read more >
How to Sort in Excel Rows or Columns Avoid Sort Problems
Avoid Sorting Trouble: Check Your Data · 1) Make a Backup of Your Data · 2) Check Your Data · 3) Fix Blank...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found