We have a dynamic datagrid with a configuration source for the columns. Because of this, we use a ngFor-loop for the clr-dg-column and utilize a trackBy function to improve performance.
We experience the issue that if the grid is initialized with selected items, the first selected item is not selected but the last item of the list. By debugging i found out, that the selection feature is using the ItemsClrDatagridItemsTrackBy<T> which sets the trackBy function of the Items Object to the trackBy of any ngForTrackBy that is found in the grid.
I got things working by removing every trackBy in the whole grid, but this isn't really a good solution for this problem.
I added a minimal example here: https://stackblitz.com/edit/clarity-light-theme-v2-bzpjmm
ClrDatagrid.items.trackBy is the column-trackByThe selection feature should only use the trackBy function of *clrDgItems or ngForOf of the clr-dg-row component and not any other unconstrained ngForOf within the grid.
App
I think the issue here is that the selector is generic for ClrDatagridItemsTrackBy: '[ngForTrackBy]' so its picking up the last trackBy to be rendered in the datagrid. We should be able to either make the selector more specific, or figure out how to filter it someway.
Hi, I鈥檓 just following up on the issue raised, is there any update on a fix?
Thanks
Hi,
do you have a workaround for this problem?
I am using
Do you have a plan to fix this issue?
@rootix The team looked into the scenario you provided and a little bit further. We came into the conclusion trackBy set on anything else than the clr-dg-row generation loop is just not needed.
We encourage you to use only trackBy on the row generation loop e.g. <clr-dg-row *ngFor="let item in items; trackBy: trackBy"></clr-dg-row> or <clr-dg-row *clrDgItems="let item in items; trackBy: trackBy"></clr-dg-row>.
Hi @bbogdanov
could you provide me with a link to the documentation on how to use the _trackBy_ function? What's the method signature?
I've looked through all 21 datagrid demos, but trackBy seems not to be mentioned anywhere. Maybe it is missing from the docs?
Nevermind, I was looking in the wrong place. trackBy is an Angular feature and not from Clarity.
Hi there 馃憢, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.