Dynamic menu with repeat

Hi everyone, I need to transform a static menu (like the one you see in the gif) into a dynamic menu that reads data from the DB.

I created 2 tables: Categories and Pages where the PA_Categoria_ID field relates the menu items to the category.

I created the connect server to read the categories and pages and I thought of using a repeat inside the other to match the menu items to the reference category but I don't think it's the correct method.

The first repeat works correctly and shows the categories, but in the nested repeat I don't know how to set the filter for the PA_Category_ID field so that I only see the menu items of the correct category.
At the moment the result is that I have all the pages inside all the categories.

How would you handle this?

Demo

Result

I usually do a subtable for things like this, but if I understand what you're trying to do correctly, I guess you could use dmx-show on the sub items and only show the subitem if the PA_Categoria_ID matches?

1 Like

Your solution works, I set the show property to the repeat of the top level.
But now I have an error when I try to make the id and the data-bs-target property dynamic through the dmx-bind method.
The HTML looks correct but there is a javascript error that I can't understand

2

Your IDs should start with a letter, not with a number.
Also, you don’t need {{ }} around your dynamic expressions: dmx-bind:id="PC_ID" is the correct syntax. If you want to add static part it will look like: dmx-bind:id="'pc_' + PC_ID"

1 Like