I would like to display 2 datasource hierarchically in a tree table.
I have 2 Datasources. ChapterDs and NotesDs.
ChapterDs : Chapters can have Subchapters and so on. This can be easily displayed hierarchically using Parent as Hierarchical Property. Does not have any association with NoteDs.
NotesDs : Note has MANY to ONE association with ChapterDs. A chapter can have a Note. A subchapter can have multiple Notes and so on.
I would like display ChapterDs hierarchically with notes associated with each Chapter or Subchapter as shown in the PDF attached.
The only way to display two data sources in one tree is to use WidgetsTree.
First of all, we should add these two data sources to our screen:
<dsContext>
<hierarchicalDatasource id="chaptersDs"
class="com.company.chnts.entity.Chapter"
view="chapter-view"
hierarchyProperty="parent">
<query>
select ch from chnts$Chapter ch order by ch.name
</query>
</hierarchicalDatasource>
<collectionDatasource id="notesDs"
class="com.company.chnts.entity.Note"
view="note-view">
<query>
select nt from chnts$Note nt
</query>
</collectionDatasource>
</dsContext>
Then we should do some basic stuff and implement WidgetBuilder for the our WidgetsTree: