I know of "i" as the index of rows in tables, but is there an equivalent index for groups?
No, I don't think there is, but here's a funny way of doing this, which might not be so efficient though. You can find the index in the group using this;
{{ self.data.filter(x => currentSourceRow.category === x.category).map(x => x.id).indexOf(currentSourceRow.id) }}
Maybe also try to do sorting if needed.
Thank!
I can't say I understand that JS very well, but from the example it seems to relate to the index of rows within a group.
What I want is not any index of rows, but the index of the actual group that the row is in.
Group:1
Row:1
Row:2
Row:3
Row:4
Group:2
Row:1
Row:2
Group:3
Row:1
Row:2
Row:3
So for any given row, I want to know which Group it is in; 1, 2 or 3
In that case, you can do this;
{{ Object.keys(_.groupBy(self.data, 'category')).indexOf(currentSourceRow.category) }}
Thanks!
That "magically" does the trick!
Replacing "category" with the column I'm grouping by in...
{{
Object.keys(_.groupBy(self.data,
'category')).indexOf(currentSourceRow.category)
% 2 ? "colourA" : "colourB"
}}
...I can colour the alternate groups differently with .... % 2 ? "colourA" : "colourB"
even though the grouping column is non-numeric.
Yes! You can do that since you can now have the group indexes.