Display based on Recursive table definition

Hi,

i’ve created a table that holds a field wich is a list of same elements and a field for parent record.
As to create a hierarchy of same elements :
Table :

  1. Name - Text
  2. Children - List of Tables
  3. Parent - Table

So, in my Table, i have some “head” elements where Parent is empty, and some of those “Parents” have several children (each children having in its Parent field a reference for its parent).

My thing is how can i display in a Repeating Group the very same hierarchy this way :

  • Parent 1
  • Parent 1 - Child 1.1
  • Parent 1 - Child 1.2
  • Parent 2
  • Parent 2 - Child 2.1
  • Parent 2 - Child 2.2
  • Parent 2 - Child 2.3
  • Parent 3
  • Parent 3 - Child 3.1
    and so on …

Doing a Merge doesn’t match as the list wouldn’t be sorted by the parent’s name.
i tried what @NigelG’s LEFT OUTER JOIN (SQL Joins Vs Bubble) but that wouldn’t do it neither as i won’t have just the parent (i’ll have Parent + all of its children).

And, i’m not familiar enough to see any other option…

Any idea ?

Thanks,

Best regards,

Guillaume

Hi Guillaume,

I think you want to achieve what is in my screenshot below:

Correct me if I am wrong.
Note I am not using tables but lists as the data type.

  1. To do this I have the outer repeating group, layout style set as full list with 1 row * 1 column. You can sort this list eg by the parents text, descending /ascending and display text elements.
    2.Inside this i have a group, this group has the setting checked, collapse group’s height when hidden. It is invisible. In conditional it is made only visible if current cell’s children first item is not empty.
  2. In this group i have another repeating group, again layout style full list 1*1 column with the list of children of each cell.

let me know if you need further help
happy bubbling,
Julius

Some screenshots to help:

Hi Julius,

thanks for your answer. It’s “almost” that but …

according to your example, i would have a row per element :
Row 1 : groceries
Row 2 : groceries - apples
Row 3 : groceries - pears
Row 4 : movies
Row 5 : books
Row 6 : books - harry potter 1
Row 7 : books - the hobbit
Row 8 : books - the bible
Row 9 : travel spots

and so on …

And each row can be “selected” …

best regards,

Hi Guillaume.

1.To display books or the bible I have always used current cells text.
For the inner repeating group, to have it say books then The bible:
Just enter as dynamic data: current cells parents text, current cells text. Instead of just current cells text. (Use 1 or 2 text elements) as you like

2.To make it a row per element make the design exactly the same for both repeating groups.

3.To make the rows selectable. In data, you can add a field to the user called users selected list (type list (table in your case) or users selected listS (a List of lists)
4.When the text from above is clicked add the workflow make changes to user: users selected list= current cells list or users selected listS add current cells list. You can then display the selection in a group/repeating group with source current users selected List (S)

Hope this helps and I understood you correctly.
Julius

Hi Julius,

in fact, i’m trying to find a way to have just one RG and no nested RG.

I’m using some old dev habits using regluar DB reflex . In that case, if the dev tool couldn’t provide a way, iw ould have used some kind of a DB view to merge the two lists (merging two SQL query with a UNION, one with no parent and another one with the parents and just have two fields with the parent text and the child text - the latter being empty for each parent-only value).

whatever element selected in the RG, it’ll always be an element of the same type. Then referencing it into other tables will be easier and i’ll be optimizing all my DB stuff.

Using your example, Books and the Bible are two different records of the same table. But bible is a child of Books. Exactly like categories and subcategories (like for this very forum).

Thanks again for taking time to answer :slight_smile:

Best regards,

Guillaume

Here is an example of the situation : https://bubble.io/page?name=index&id=recursivetable&tab=tabs-1

the idea is to get, in step 2, the configuration with an Parent-only or Parent-Child per row in the repeating group…

Thanks,

Guillaume

Hi Guillaume,
I think I managed.

  1. When you create lists add them to the current users lists (new field for user: list of lists ). Give them an order nr (new field: number) which is current users lists count + 1.
  2. When you create sublists, do not add them to current users lists but add them as children to the parent list. As their order nr: input formula in screenshot below. it makes the order nr of the sublist, the order nr of the parent + how many sublists this parent has * decimal. This allows you to sort the merge according to order nr. (if you need not 10 but 1000 sublists then do *0.001)
  3. In the repeating group source: current users children lists merged with current users lists sorted by order nr descending = no.
  4. in the repeating group have 2 texts. Under conditional of the texts, show text 1 (current cells text): if current cells parents = empty; show text 2 (current cells parents texts - current cells text) : if current cells parents is not empty
1 Like