Mendix widget to use AntDesign TreeSelect. The widget is designed to display a list of objects that have a self-association or do raw JSON input and output.

- Search the data set
- Data source can be Mendix Objects or raw JSON
- Can show the options as checkboxes or cells
- Option to use tree lines
- Option to have all context expanded or collapsed by default
- Select a reference or reference set
- Download the mpk file from GitHub or the Mendix Marketplace.
- Copy the mpk file to your Mendix Project directory
{YourMendixProjectFolder}/widgets/. - Open your Mendix Project with Mendix Studio Pro and click on the menu
Menu > App > Synchronize App Directory.
The entity you want to display must include an attribute that uniquely identifies an object. For me, this is the ItemNo AutoNumber.

Note:
- The "Item" entity will be displayed in the dropdown
- The "ItemSelection" entity is the owner of the association that is set when option(s) are selected
- If you are using Input Type "JSON", you will need 2 non-persistent entities to store the state of the widget and manage the selected objects

Note: Checkable is only allowed if Reference Type = Reference Set

Input Type - How the widget expects to receive the selectable objects and how the widget sets the selected value. Detailed setup for both types below.
Reference type - Should the user be able to select a list of options of only one option?
Selection Type - Determines which items get returned if a parent and all of its children are selected (Only for reference sets)
| All | Parent only | Children only |
![]() |
![]() |
![]() |
The widget will generate the widget's structure using the selected data source.

Note:
- Parent key must be the SAME attribute as the key but navigates across the self-association. It is used to match each child with by its parent's key
- If the parent key for an object is empty or is not found, the widget will display that record as a root option
- Association is the reference set on the page object that get set when the user selects an option
- Large data sets can run into performance issues while converting the data, consider using JSON mode

Tree data type - Controls which JSON structure the widget expects.
| Flat | Tree |
[
{
"label": "",
"value": 0,
"id": 0,
"pId": 0
}
] |
[
{
"label": "Node1",
"value": 0,
"children": [
{
"label": "Child Node1",
"value": 0,
"children": [
{
"label": "Grand Child Node1",
"value": 0
}
]
}
]
}
]Note: You can add as much depth as you need. Just add more children to the lowest level of the JSON structure |
- Create a JSON Structure using the JSON Snippets above. If your unique identifier is a string, change the integers in the structures below to also be a string.
- Wrap the widget with a data view.

The functionality of DS_TreeSelectHelper and the On Change action depends on the reference type: reference or reference set:
- DS_TreeSelectHelper returns the TreeSelectHelper from the domain model above.

3a. Retrieve across the reference you're going to set to see if there is already a value. If there is no current value, be sure to set $TreeSelectHelper/Selected as empty. Setting '' does not work.
3b. For Tree Data Type "Flat", retrieve all the objects you want displayed. For Tree Data Type "Tree", ONLY retrieve the root level objects. Children will be retrieved by the subsequent export mapping.
3c. Use an export mapping to get the JSON structure for your selectable objects. These should be based on the JSON structures in the Tree Data Type section above.
- DS_TreeSelectHelper returns the TreeSelectHelper from the domain model above.

3a. Retrieve across the reference you're going to set to see if there is already a value. Export that list by creating a JSON Structure with the following. If your unique identifier is a string, encase the 1 with quotation marks.
[1]Then, use that JSON Structure to create the following Import and Export Mappings. "Value" should be your entity's unique identifier ... in my case ItemNo.
| Import | Export |
![]() |
![]() |
3b. For Tree Data Type "Flat", retrieve all the objects you want displayed. For Tree Data Type "Tree", ONLY retrieve the root level objects. Children will be retrieved by the subsequent export mapping.
3c. Use an export mapping to get the JSON structure for your selectable objects. These should be based on the JSON structures in the Tree Data Type section above.
- Add an on change microflow that converts the JSON stored on the "selected attribute" back to Mendix objects.

4a. Use the Import mapping from #3a and import from $TreeSelectHelper/Selected.
4b. Iterate that list and retrieve the original objects by their unique identifier attribute.
4c. Change the page object's reference set to the list retrieve by the loop.
https://demo-antdwidgets100-accp.apps.ap-2a.mendixcloud.com/p/tree-select
https://github.com/bsgriggs/mendix-tree-select/issues
- Install NPM package dependencies by using:
npm install. If you use NPM v8, which can be checked by executingnpm -v, execute:npm install --legacy-peer-deps. - Run
npm startto watch for code changes. On every change:- the widget will be bundled;
- the bundle will be included in a
distfolder in the root directory of the project; - the bundle will be included in the
deploymentandwidgetsfolder of the Mendix test project.
Benjamin Griggs Jonathan Schmitt









