OL Learn

Array index summary per page


looking for a solution, I have a detail table with overflow to n-pages.
On each page I need to present the first and last detail line number of that particular page.
As each detail line, can contain a multi -line row, I can’t determine upfront number of detail lines on a page.
Is there any method to determine first and last indexnumber per page on a detail tabel?
Any advice much appreciated!

Belate answer and not sure if it was possible at the time. But guess the example could be handy for people looking for Post Pagination script examples. The following script iterates over each detail table after the pagination process (selects the tables by the .table–minimalist class).

It retrieves the data row reference based on the data-record-reference attribute which is added by the latest dynamic table implementation introduced in Connect 2020.1. Note that the index numbers are zero based therefore the extracted index number is cast to an integer using parseInt so we add 1.

The script also retrieves the page of the current table. With some CSS selector magic we use this to locate an absolute position box on the respective master page.

Last but not least the index of the first row and last row are written to the abs box on that master page.

Added my template and datamapping config with the full example.

merge.context.query('.table--minimalist').each( function() {
	var firstRow = query('tbody tr:first-child', this);
	var firstRowIdx = firstRow.attr('data-record-reference').split('_').pop();
	firstRowIdx = parseInt( firstRowIdx ) + 1;
	var lastRow = query('tbody tr:last-child', this);
	var lastRowIdx = lastRow.attr('data-record-reference').split('_').pop();
	lastRowIdx = parseInt( lastRowIdx ) + 1;
	var page = this.info().pageNo;
	var masterPageObject = query('.page_bleedbox:nth-child(' + page + ') .detailRowInfo');
	masterPageObject.text( 'rows ' + firstRowIdx + ' - ' + lastRowIdx  )

labglass-fields.OL-datamapper (9.2 KB) labglass-invoice-post-pagination-test.OL-template (88.1 KB)