This section will describe how data is initialized and triggered in a page. When you loads a page from the server, this is done by two definitions. First you have a template with a body and then you have the page that is added to the body part of the template. Both of the definitions can have data. These are merged into a page data tree before generating the page. 

How do a page tree look like

Root table 1
    Child table 1
        Children's child table 1
        ...
        Children's child table N
    Child table 2
    ...
    Child table N
Root table 2
    Root 2s child table 1
    ...
    Root 2s child table N
...
Root table N

There can be a lot of tables at each level of the tree and each of them can have their own children than can also have children etc. There can be a lot of tables at many levels, but usually it is just one at each level with data. There for we can make a simpler default model that is the one used in most of the reports generated from DataEase.

Root table
    Child table

This tree then become .header items .footer when we have two levels and two headers, one items and two footers if we have tree levels. 

Added to this we also can have stats/aggregates. These are sum, count etc. added to a field. These will show up in all levels from the one it is defined in and up to the root.

Root table
    Child table with stats like sum and count
    Stats for Child table for child table level
Stats for Child table for root level

Added to this again we can have groups with it's group header and group footer. What this means in the model is an extra level on a single field where each values this field can have is grouped together and listed separate. The data will then have two level with the same table name, where the first only have one field and the rest of the fields in the table are listed in the next level.

How next record is triggered

When a page is loaded, all data are generated before the page is generated. Before any page text is generated, all data is initialized to the point at the first record. The next record in a level is triggered by the end of a section.

".items" will trigger next record for it's own level at the end of items. This means that all items at the level will be sent to the page before any other data is added.

".footer" will trigger next record for the corresponding ".header" and restart processing at that header.

".group footer" will trigger next value in ".group header and initialize the corresponding record in the level below as these two are tied together. Then it will restart processing the corresponding ".groop header".

What is there is not enough headers, footers, group headers and group footers or even a missing items/end. As stated earlier, when a page is initialized for data processing all levels in the data tree is initialized to first record (it it exist, if not a empty record is added). The page generator knows how many header, group header and footers and group footers that are expected. The items work independent of headers and footers as they only do a list of all their data at once. If there are to few headers, a empty header are added for all levels up to the first that have a header. If no headers are found before the ".items" are reached, all empty headers are added before the ".items" are done. The same are done for footers. When the last footer found have come to the last record in it's level, the missing levels will be added directly after it.

<h1>Order [{OrderNo}]<h1>
<table>
.items
<tr><td>[{StockCode}]</td><td>[{Description}]</td><td>[{Count}]</td><td>[{Price}]</td><td>[{TotalPrice}]</td></tr> 
.end
</table>
<p>Total: [{OrderTotal}]</p>

The following have two levels but do not have any headers or footers

<h1>Order [{OrderNo}]<h1>
<table>
.header
.items
<tr><td>[{StockCode}]</td><td>[{Description}]</td><td>[{Count}]</td><td>[{Price}]</td><td>[{TotalPrice}]</td></tr> 
.end
</table>
<p>Total: [{OrderTotal}]</p>
.footer
.end

The one executed will look like this for the page generator. If there where more levels more headers and footers would be added at the same locations. If there are headers or footers and there are to few, the extra headers will be added before the first real header and the extra footers would be added after the last real footer.

Examples

.dql
for Address
list records
  Name;
  EMail;
.end
<h1>Addressees</h1>
<table>
.items
<tr><td>[{Name}]</td><td>[{Email}]</td></tr>
.end
</table>

Here in this simplest examples the .end of items will trigger next record and continue to loop through all the records in the Address table. If you had removed the .items/.end from the definition, only the first record in Address would be listed.