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
This table allows the user to refresh the current page, change pages, and select multiple items.
The Issue I'm Seeing
Since we recreate the rows whenever the paging or refresh occurs, the references will no longer match what may have been in the previous selection array.
So, I found selectionMatchFunction which was added ~v3.0 which is seemingly meant to address this issue. It works for the most part - it correctly renders rows as selected based on my own criteria defined in selectionMatchFunction (compare ID instead of object ref).
The issue is that the select function in the TableRowMeta class doesn't seem to respect the selectionMatchFunction. I think there are two main areas here to address:
The use of Set to maintain uniqueness of selected elements is always going to do an object ref compare
Even if we converted the Set to an Array, we'd need to update any functions that add/remove elements or do equality checks to use selectionMatchFunction in the same way we do for the isSelected and isGroupSelected CPs.
For example, in the range selection branch within this function we add the rows to the Set, assuming that any dupes will be removed, without asking selectionMatchFunction if they are actually dupes:
The result of this is that we end up with either 1) dupes in the selection array, or 2) elements not being un-selected when they should be.
Brain dump over - I hope I explained this well enough. When I get a few minutes this week I'll put together a gist. If this seems like a real issue to folks, I can put together a PR.
The text was updated successfully, but these errors were encountered:
Use Case
I'm building a table that is populated by rows that are POJOs which combine info from multiple E-D models. Example psuedocode:
This table allows the user to refresh the current page, change pages, and select multiple items.
The Issue I'm Seeing
Since we recreate the rows whenever the paging or refresh occurs, the references will no longer match what may have been in the previous
selection
array.So, I found
selectionMatchFunction
which was added ~v3.0 which is seemingly meant to address this issue. It works for the most part - it correctly renders rows as selected based on my own criteria defined inselectionMatchFunction
(compare ID instead of object ref).The issue is that the
select
function in theTableRowMeta
class doesn't seem to respect theselectionMatchFunction
. I think there are two main areas here to address:Set
to maintain uniqueness of selected elements is always going to do an object ref compareSet
to anArray
, we'd need to update any functions that add/remove elements or do equality checks to useselectionMatchFunction
in the same way we do for theisSelected
andisGroupSelected
CPs.For example, in the range selection branch within this function we add the rows to the Set, assuming that any dupes will be removed, without asking
selectionMatchFunction
if they are actually dupes:ember-table/addon/-private/collapse-tree.js
Lines 188 to 197 in f9d05b3
The result of this is that we end up with either 1) dupes in the selection array, or 2) elements not being un-selected when they should be.
Brain dump over - I hope I explained this well enough. When I get a few minutes this week I'll put together a gist. If this seems like a real issue to folks, I can put together a PR.
The text was updated successfully, but these errors were encountered: