Form having same table in two different group, header and detail

Hello all,

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:

  1. Create two data sources with the same underlying table (let’s call them GroupDS and LineDS). Set LineDS’es JoinSource to GroupDS.
  2. 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.)
  3. 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


  1. Sure, there has to be a relation to your table itself. You could also add a dynalink in the form.

  2. Unfortunately AX drops the GROUP BY clause for some reason. It’s possible to add it back in executeQuery(), however I was not successful in getting ORDER BY working.

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:

QueryBuildDataSource qbds;
Query q = this.query();

qbds = q.dataSourceTable(tableNum(MyTable));
qbds.addSortField(fieldnum(MyTable, Hdr1), SortOrder::Ascending);
qbds.addSortField(fieldNum(MyTable, Hd2), SortOrder::Ascending);
qbds.addGroupByField(fieldnum(MyTable, Hdr1));
qbds.addGroupByField(fieldnum(MyTable, Hdr2));



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?