cancel
Showing results for 
Search instead for 
Did you mean: 

OpenUi5 Tree Element without JSON

0 Kudos

I want to "convert" a JSON Object to C++ model so that my tree will take the datta from C++ side.

I have a simple tree:

<Tree 
  id="Tree" items="{path: '/ftree'}">
  <CustomTreeItem>
    <Input value="{text}"/>
 </CustomTreeItem>
</Tree>

Let's say I have this simple JSON

nodes:[{text:"Node1"},{text:"Node2",
nodes:[{text:"Node 2-1"}]}]

In C++ I have this structure:

struct nodes {
std::string text;
nodes()=default;
nodes(const std::string &text): text(text){}};

I also have a second "main" structure with a lot of other elements and it's like this:

structTree{

std::vector<nodes> ftree;}

In main I give the data:

Tree model;
model.ftree.push_back(nodes("Node 1"));
model.ftree.push_back(nodes("Node 2"));
model.ftree.push_back(nodes("Node 2-1"));

It's working but it takes all the nodes in the first level. How can I give data to a node inside?

Thank you

Accepted Solutions (0)

Answers (0)