Dynamic Dropdown only shows first record

Trying to create a dynamic dropdown menu.

Have a server connect instance which querys records from my category table, on of the fields is the Category Name.
The Dropdown Menu has a repeat on it and its expression is the server connect query.

The Dropdown Item looks for its Text using the Category Name of the repeat.

When I test the page I only see the first record of the category table, anyone any idea whats going wrong?

Please post your dropdown code here.

<dmx-serverconnect id="serverconnect1" url="/dmxConnect/api/Menus/Main Menu.php"></dmx-serverconnect>
    <div class="container">
    <div class="row">
    <div class="col">
    <div class="dropdown">
      <button id="dropdown1" class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown button
      </button>
      <div class="dropdown-menu" aria-labelledby="dropdown1" dmx-repeat:repeat1="serverconnect1.data.query">
        <a class="dropdown-item" href="#">{{cat_name}}</a>
      </div>
    </div>
    </div>
    </div>
    </div>

I am just guessing here but it could be the space in your API file name. (Main Menu.php)

The repeat should be a repeat children on the parent or move the repeat part to the item.

<div class="dropdown-menu" aria-labelledby="dropdown1" dmx-repeat:repeat1="serverconnect1.data.query">
    <a class="dropdown-item" href="#">{{cat_name}}</a>
</div>

Becomes

<div class="dropdown-menu" aria-labelledby="dropdown1">
    <a class="dropdown-item" href="#" dmx-repeat:repeat1="serverconnect1.data.query" >{{cat_name}}</a>
</div>
3 Likes

Repeat region repeats the element it is applied to, repeat children repeats the child element inside the element it’s applied to.
So @bpj’s suggestion is correct. You need to repeat the child elements of the dropdown, not the dropdown itself.

Also, it’s never a good idea to have empty spaces in the server action names. Main Menu is not a good naming practice. Better use Main_Menu or main_menu or MainMenu - spaces are never a good idea.

2 Likes

Thank you to you all.

@bpj , your suggestion worked first and @Teodor, I have changed the action name to not have any spaces.

CK