Have a look at the solution below
Datamodel
The Main/Sub category are both modeled as seperate entities and the Sub_Main association determines which subcategory belongs to which main categories.
The selectionhelper entity is used to pick a main and subcategory
Page
On the page you can use reference selectors, to pick the main and sub category.
Filter on sub reference selector
On the sub reference selector you need to apply an xpath filter, such that only the subcategories associated with the selected main category is shown.
[TestSuite_Default.Sub_Main/TestSuite_Default.Main/TestSuite_Default.SelectionHelper_Main='[%CurrentObject%]']
Hi
Refere the folloing link, it is in detail
https://docs.mendix.com/refguide/reference-selector#xpath-constraints
Desgin you Domain model as like this and can add some data by assocaiting each and based on x-path you can show it in the client side