How to build a Hierarchical datasource to use the Tree table object ?

Hello,
I am testing the Cuba Platform and so far, it is just “exceptional” as I am a low level programmer.
I am trying to build a simple hierarchy (table name - employee) including a child and its parent. So I created 2 columns, and for the parent field, I did an association referencing the employe table.
But then, when I create the edit screen, only the child field is available. If I create a Tree table in the browse screen, I get a java exception.
Could you help to find the good way to do it ?
Many thanks,
FBS

2 Likes

Hi,

can you share the entities java class definitions and the screen’s xml in order to better understand your problem?

That would be great.

Bye
Mario

Hello, Frédéric.

I advise that you use Cuba Studio. You can download it here.

Let’s create new project and add new entity:

  1. Open DATA MODEL tab

  2. Click New and choose Entity

  3. Add new fields to the entity:

After that you have to create new view for the Employee entity:

  1. Right click on the Employee entity

  2. Choose Create view

  3. Tick firstName, lastName, chief, chief > firstName, chief > lastName

  4. Click OK

Now we can create generic screens:

  1. Right click on employee-view and choose Create Generic UI screen

  2. Choose Entity browser and click Create

  3. Choose Entity editor and click Create

Let’s tune our browse screen:

  1. Open GENERIC UI tab and double click on employee-browse.xml

  2. Open DATASOURCES tab and choose hierarchicalDatasource instead of groupDatasource

  3. Open LAYOUT tab, right click on table and choose Convert to TreeTable

  4. Click OK

Now you can run you app pressing CTRL+SHIFT+F9 and check how everything works.

employee

employee-view

employee-screens

employee-datasource

employee-result

1 Like

Dear all,

I finally succeeded. My view was incorrect. MANY MANY Thanks for such a quick answer. I am discovering cuba and I am loving it more and more.

I loaded a big Hierarchy table to try it and I found that if I have more than 4 level, then level 5 and above are creating individual lines while there are also part of their normal hierarchy. Is it a bug or a normal behavior with a specific setup. I will open a dedicated thread for this topic.

FBS.

I’ve tried to reproduce the issue and haven’t found anything strange:

Could you share your project and test data?

treeTableTest

Thanks for trying to reproduce. Unfortunately, I cannot share my database.
One potential idea : I have several level 1 nodes (nodes with no parents). Is the tree table supposed to handle that ?
Otherwise, I did checked it completely and recreated all parent child relationship using UUID fields. It worked in a better way as long as I do not have too many data. I am still working on many data integrity checks (could be the issue). I did not find any problem at the moment.
What I am currently doing is build a similar database with dummy data (more than 20000), with a minimum of 6 level to try to reproduce it in a dummy database. As soon as it is ready, I will post it.
Many thanks for your support.
FBS

TreeTable supports nodes without parent and shows them in the separate group.

OK, we will wait for the results of your test.

in this hierarchical table i need multiple selection

example: parent is “skill” and children are name of skill.
if I want to select more then 2 skill. i need to select skill press ok and select other skill press ok, every time I want want to select again and again

so that I want to use Multiple selection in this table and click ok. selected all Item want to add in my skills

thank you in advance

Hi,

Try “mutliselect=true“ in the tree table tag.

Then multi select with CRTL + click…
In the docs you can search for multiselect and find information about it as well.

Bye