Filter datagrid2 based on the selected attribute from tree structure

0
Hello Mendix Community, I’m working on a Mendix project (v10.6.10) where users upload an Excel file that creates a tree structure of categories (Category0 → Category5). Each MiBElement is associated with the deepest applicable category. A tree view is used to display the categories, and when a node is selected, the MiBElements associated with that node (and its children) should be displayed in a DataGrid. Here’s the intended functionality: Selecting any category (even at the child level like Category4 or Category5) should display all MiBElements associated with that node. The filter should also reflect the full parent path (e.g., Category0 → Category1 → Category4) so that sibling categories are not incorrectly shown. We created a microflow that handles both filtered and unfiltered MiBElement retrieval. We also created nanoflows for setting the selected category at each level and storing the selected category path in a non-persistent helper entity. Issue:Despite setting the correct category in the helper entity and ensuring associations are properly configured, the filtering is not working as expected:
asked
1 answers
0

Hi Ashmitha Kalkur

To filter DataGrid2 based on a tree selection in Mendix, start by setting up your domain model with a Category entity (used in the tree) and a Product entity (displayed in DataGrid2), connected via a many-to-one association (Product_Category). Use a Tree Node widget from the Mendix Marketplace or a custom widget to create the tree structure, sourcing the data through XPath or a microflow that returns the Category list. When a node is clicked, trigger a nanoflow or microflow that stores the selected category in a helper object—a non-persistent FilterContext entity associated with Category. In the nanoflow, either retrieve or create this FilterContext, set its selectedCategory to the clicked node’s category, and refresh the object if needed. For the DataGrid2, set the data source to XPath with a constraint such as [Category = '[%CurrentObject%]'], and ensure the FilterContext is passed as the context object to the page or surrounding Data View. Alternatively, use a microflow data source to filter the product list based on the selected category. For a more responsive experience, wrap the tree and DataGrid2 inside a Data View of FilterContext and refresh this context object via a flow on tree node click to enable live filtering

I hope this helps in identifying and resolving the issue.

Thanks

answered