-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Improvement: Fire <b-table> filtered-event when filteredItems array gets modified #1989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Each time the table is altered (even if not filtered), the filteredItems is updated (i.e. a new slice is created, creating a new table reference). One would need to do a deep (or possibly a shallow) comparison of the previous contents of filteredItems vs the new Contents of finteredItems. There is a utility method in BootstrapVue that can do this type of comparison (it is used for comparing form-select, form-radios, form-checkboxes. It could be used here as well. |
Ok, thanks for the explanation :) |
During the process that computes the items (which could be driven by a provider), the filter process runs, and a new reference to a filtered array is created and stored in So even if the filtered items remain the same (say after a local pagination). which means that with your suggested code change, the A shallow/deep comparison of
|
In the current state of the
b-table
component the filtered event only gets fired when the length of the filteredItems array changes.But there may be use cases when the length of the array does not change, but the array items itself have changed/ have been modified.
In my particular case i am implementing a dynamic scrolling for the table where data is fetched/loaded blockwise and pushed in rather then spliced out the items array, so that the count does not change at all.
My suggestion: Would it be possible to change the watcher for the filteredItems array to watch for array mutation instead of array length? Or are there any side effect (performance issues) that i did not think of?
Original:
Improved:
The text was updated successfully, but these errors were encountered: