Tracking subscriptions in one table. A subscription can be nested by recording the “parent” subscriptions id in a field called “parentsub’.
I need to pull the subs where parent sub is blank, then if that subscription has children i need to pull those.
I have this working but probably not the way i should be doing it. I use a flatten to get a variable to get a list of the parent subscriptions id’s and then use a repeat to search for children and it produces the correct data. So two outputs, subs and childrensubs are seen in the output.
The issue I’m having is i need to display this. I have a table that generates for parent or standalone subscriptions. What is everyone doing to display a dataset like this
*ParentSUB
ChildSub1
ChildSub2
*Standalone Sub
I use the same table structure as you, where parent and child relationships live in the same table, but a 'parent_link_id' column is used to identify a child link (it will have a parent_link_id).
Here's what my parent repeater looks liks:
<!-- Main REPEATER -->
<div class="d-flex flex-column gap-3" id="listLinks" is="dmx-repeat" dmx-bind:repeat="scListLinks.data.getLinks.where('parent_link_id', null, '==')">
And here's the nested child repeater snippet:
<!-- Child Links Repeater -->
<div class="bg-white border-top ps-5 pe-3 py-3" dmx-show="scListLinks.data.getLinks.where('parent_link_id', link_id, '==').hasItems()">
<div class="d-flex flex-column gap-2" is="dmx-repeat" dmx-bind:repeat="scListLinks.data.getLinks.where('parent_link_id', link_id, '==')">
The page that allows the creation of links, also allows for making links visible or hidden. If a parent link is marked hidden, then all child links are hidden as well. That's what the first DIV tag does in the Child repeater. The next DIV is how I build rows for child links that have a parent_link_id. HTH
1 Like
I think i follow this and the first part was easy, limiting the first repeat to only those with a null parent record.
It’s the second part i’m struggling with, showing the children. I have inside the responsive table, a second table body… which might be the mistake. Should it be a second table body or just use the first, but then i’m not sure how to essentially do a second filter based on repeat2.parent_id = repeat1.id of a child record.
I use bootstrap's card class but the logic is the same. The parent starts the card class and puts rows onto the page using card-body. When the child repeater starts, it creates a new card class and puts all the child info in a card-body.
So, you'd start the parent with a table and use the repeat in table rows. When you get to the child repeater, you'd start a new table and use the repeat on the child rows. This should properly nest a child table within a parent table. Although, I'm not quite sure how that would look, which is why I like using card and card-body. I find it easier to style than bootstrap's table class.