I was just wondering, I am trying to mimic the tree from 1.5 and the only way is to use the treeDataGrid and make some changes (hide header, etc).
However I can’t make it load the data using a DTO.
Below is the DTO:
@JmixEntity(name = "sim_NavigationTreeNode")
public class TreeNode {
private String name;
private String type;
private TreeNode parentTreeNode;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public TreeNode getParentTreeNode() {
return parentTreeNode;
}
public void setParentTreeNode(TreeNode parentTreeNode) {
this.parentTreeNode = parentTreeNode;
}
}
Below is the view:
@Route(value = "browse", layout = MainView.class)
@ViewController("sim_BrowseView")
@ViewDescriptor("browse-view.xml")
public class BrowseView extends StandardView {
private final Logger log = LoggerFactory.getLogger(BrowseView.class);
@Autowired
private DataManager dataManager;
@Install(to = "treeNodesDl", target = Target.DATA_LOADER)
protected List<TreeNode> treeNodesDlLoadDelegate(final LoadContext<TreeNode> loadContext) {
TreeNode parentTreeNode = dataManager.create(TreeNode.class);
parentTreeNode.setName("ACME Ltd.");
TreeNode dateTreeNode = dataManager.create(TreeNode.class);
dateTreeNode.setName("25-11-2023");
dateTreeNode.setParentTreeNode(parentTreeNode);
List<TreeNode> treeNodes = new ArrayList<>();
treeNodes.add(parentTreeNode);
treeNodes.add(dateTreeNode);
return treeNodes;
}
}
… and the xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<view xmlns="http://jmix.io/schema/flowui/view"
title="msg://browseView.title">
<data readOnly="true">
<collection id="treeNodesDc"
class="nl.dm.simon.simonuserwebapp.entity.TreeNode" fetchPlan="_local">
<loader id="treeNodesDl" cacheable="true"/>
</collection>
</data>
<facets>
<dataLoadCoordinator auto="true"/>
</facets>
<layout>
<split orientation="HORIZONTAL" width="100%" height="100%" splitterPosition="25">
<vbox height="100%" width="100%" expand="treeNodesDataGrid">
<treeDataGrid id="treeNodesDataGrid"
hierarchyProperty="parentTreeNode"
width="100%" dataContainer="treeNodesDc"
minHeight="20em">
<actions/>
<columns>
<column property="name"/>
</columns>
</treeDataGrid>
</vbox>
<vbox height="100%" width="100%">
<split orientation="VERTICAL" width="100%" height="100%" splitterPosition="30" themeNames="small">
<hbox width="100%">
<label text="Label"/>
<textField placeholder="TextField"/>
</hbox>
<hbox spacing="true">
<button text="Button"/>
<button text="Button"/>
</hbox>
</split>
</vbox>
</split>
</layout>
</view>
The data is not loaded in the treeDataGrid, it displays as an empty container.
What am I doing wrong ?
Thanks.