I have successfully created dynamic menus using a recursive function, and they are displaying in the correct order without any issues.
Requirement:
My current goal is to identify the last level of menus and assign a checkbox with the value corresponding to their respective id {item.id}
.
Example:
For the first menu item one,
-> [Checkbox with value 1.1.1] One-One-One
-> [Checkbox with value 1.1.2] One - one - two
-> [Checkbox with value 1.1.3] One - one - three
For the second menu item two,
-> [Checkbox with value 2.1] Two - one
The objective is to replicate this structure for all menu items up to the sixth menu item six.
In summary, I need to identify the last hierarchical level of children, as shown in the above example, and associate a checkbox with the corresponding id
value.
Please refer to the code snippet below to assist me in achieving the desired outcome of adding checkboxes at the last level.
Note: The checkboxes must be displayed in line with the last level elements, similar to the provided example, with checkbox values matching their respective id
.
This requirement arises from having multiple submenus where the last level contains filter values. When a checkbox is clicked, the value is passed to an api
to retrieve related data associated with the selected menu item. However, my immediate concern is creating checkboxes that correspond to each menu item.