I need to create a form having two grids, header and detail, but where the table is the same in both grids.
In the header I need a group by of some fileds of the table, whereas in the detail I need to show all the records related
to the header.
How can I create this? Any example?
It is quite straightforward:
- Create two data sources with the same underlying table (let’s call them GroupDS and LineDS). Set LineDS’es JoinSource to GroupDS.
- Define grouping logic in GroupDS.init(), using FormDataSource.addGroupByField() and addSelectionField() methods. Ask if you need more details about that.
(You could also build it as an AOT query.)
- Create two grids and be sure that their DataSource property points to right data source.
Already done exactly you said but with no success:
1st) the dtl is not correct and contains all recs, could be something to define at table/relations level?
2nd) if click on one column of the header for sort, the group by disappears
Hi, doesn’t work:
in MyTable.relations added its own relation based on rhe two fields Hdr1 and Hdr2
In the form defined the two ds MyTableDS1 and MyTableDS2 join source on DS1, delayed
In the DS1 executequery() added the following:
Query q = this.query();
qbds = q.dataSourceTable(tableNum(MyTable));
qbds.addSortField(fieldnum(MyTable, Hdr1), SortOrder::Ascending);
qbds.addSortField(fieldNum(MyTable, Hd2), SortOrder::Ascending);
but the group by drops when done something on the 1st grid, and not right records showed in the 2nd grid (some blank lines, lines of other headers and so on…)
Any other suggestion?