fixed rows within a Details Table

Hi,

Is it possible to have some rows with fixed values inside the details table? However the rows will only be displayed under a certain condition, in the example below, if “item bundle” is displayed, there would be some subitems displayed. These subitems have fixed values is in yellow while the Items from Details table is in cyan.

ItemDescriptionQty
Item 1Item Description 110
Item bundleItem Description 21
sub item 1 sub item description 15
sub item 2 sub item description 26
sub item 3 sub item description 37
Item 3Item Description 31

Hi Ian,

I’m assuming that the static info will always be the same for a row that contains “ItemBundle” within a detail table. This is my take on how to do this. You can probably expect a OL dev to chime in and make my method minuscule but hey we are all learning and I like new challenges.

Download

Hope this helps.

Regards,

S

Ok, if the sub items are static and will always have the same values in numbers and qunatities, then simply deign your dynamic table, then add a script which tragerts the following selector: #table tbody tr:

const subItems = "<tr><td>sub item 1</td><td>sub item description 1</td><td>5</td></tr>" 
				+ "<tr><td>sub item 2</td><td>sub item description 2</td><td>6</td></tr>" 
				+ "<tr><td>sub item 3</td><td>sub item description 3</td><td>7</td></tr>";

results.each(function(i) {
	if(record.tables["detail"][i].fields["Item"]== "Item bundle"){ 
		this.after(subItems);           	
	}
});

However, if the sub items are also dynamic in nature and their quantities from 1 to n sub items, then we are talking about nested dynamic tables which can be achieved in several ways based on your data mapper. Please confirm whether this is the case.

Hi Rod,

thanks for your reply, actually the details for the sub items would come also from the details table in the datamapper module, it’s only matter of displaying it at the print file, The only challenge that remains is that if the rows reached 8, how would the designer program print the same page that contains the remaining data in the table. I would also like to know how PReS Connect handles overflowing of data

Hi Sharne,

Thanks for helping me with the challenges that I’ve encountering in PReS Connect. Yes you’re correct the subitems are static and only contained 4 rows, though the data for this came from the details table of my datamapper module, It is only a matter of displaying it in the designer.

Can you share a screenshot of your data mapper?

Hi Rod,

I can give you the sample structure of the data that I’ve been working on since the data itself is confidential.

As you can see below, if the product description is not “item bundle”, it would not display any values for the sub products

detail[4] 1

<> Product Code 0066
<> Product Description item bundle
<> ProductQty 1
$ ProductPrice $10.00
<> Sub_ProductCode1 0067
<> Sub_ProductDescription1 subitem 1
<> SubProduct_Qty1 5
$ SubProduct_Price1 $2.00
<> Sub_ProductCode2 0068
<> Sub_ProductDescription2 subitem 2
<> SubProduct_Qty2 3
$ SubProduct_Price2 $2.50
<> Sub_ProductCode3 0068
<> Sub_ProductDescription3 subitem 3
<> SubProduct_Qty3 2
$ SubProduct_Price3 $3.00
<> Sub_ProductCode4 0069
<> Sub_ProductDescription4 subitem4
<> SubProduct_Qty4 1
$ SubProduct_Price4 $4.50

detail[4] 2

<> Product Code 0070
<> Product Description item sample 2
<> ProductQty 3
$ ProductPrice $15.00
<> Sub_ProductCode1
<> Sub_ProductDescription1
<> SubProduct_Qty1
$ SubProduct_Price1 $0.00
<> Sub_ProductCode2
<> Sub_ProductDescription2
<> SubProduct_Qty2
$ SubProduct_Price2 $0.00
<> Sub_ProductCode3
<> Sub_ProductDescription3
<> SubProduct_Qty3
$ SubProduct_Price3 $0.00
<> Sub_ProductCode4
<> Sub_ProductDescription4
<> SubProduct_Qty4
$ SubProduct_Price4 $0.00

detail[4] 3

<> Product Code 0080
<> Product Description item sample 3
<> ProductQty 5
$ ProductPrice $8.00
<> Sub_ProductCode1
<> Sub_ProductDescription1
<> SubProduct_Qty1
$ SubProduct_Price1 $0.00
<> Sub_ProductCode2
<> Sub_ProductDescription2
<> SubProduct_Qty2
$ SubProduct_Price2 $0.00
<> Sub_ProductCode3
<> Sub_ProductDescription3
<> SubProduct_Qty3
$ SubProduct_Price3 $0.00
<> Sub_ProductCode4
<> Sub_ProductDescription4
<> SubProduct_Qty4
$ SubProduct_Price4 $0.00

detail[4] 4

<> Product Code 0090
<> Product Description item sample 4
<> ProductQty 2
$ ProductPrice $12.00
<> Sub_ProductCode1
<> Sub_ProductDescription1
<> SubProduct_Qty1
$ SubProduct_Price1 $0.00
<> Sub_ProductCode2
<> Sub_ProductDescription2
<> SubProduct_Qty2
$ SubProduct_Price2 $0.00
<> Sub_ProductCode3
<> Sub_ProductDescription3
<> SubProduct_Qty3
$ SubProduct_Price3 $0.00
<> Sub_ProductCode4
<> Sub_ProductDescription4
<> SubProduct_Qty4
$ SubProduct_Price4 $0.00

Remember that for overflow to work, the dynamic table must be at the “root” of the template and not within another element. Any <tr> added dynamically must contain the attribute data-breakable, with a unique value, as well as the data-repeat attribute. So, for example, <tr data-repeat=“” data-breakable=“subItem0”>. These <tr> elements should be added to the <tbody>.

Since the subitems are also part of the detail table, proceed as follow:

Create your dynamic table without the subitems.

To add the subitems where necessary, use below script (edit as needed):

results.each(function(i){
	if(record.tables.detail[i].fields.ProductDescription == "item bundle"){
		
		let subProdCode = [record.tables.detail[i].fields.Sub_ProductCode1,record.tables.detail[i].fields.Sub_ProductCode3,record.tables.detail[i].fields.Sub_ProductCode4];	
		let subProdDesc = [record.tables.detail[i].fields.Sub_ProductDescription1,record.tables.detail[i].fields.Sub_ProductDescription2,record.tables.detail[i].fields.Sub_ProductDescription3,record.tables.detail[i].fields.Sub_ProductDescription4];
		let subProdQty = [ record.tables.detail[i].fields.SubProduct_Qty1,record.tables.detail[i].fields.SubProduct_Qty2,record.tables.detail[i].fields.SubProduct_Qty3,record.tables.detail[i].fields.SubProduct_Qty4];
		let subProdPrice = [ record.tables.detail[i].fields.SubProduct_Price1,record.tables.detail[i].fields.SubProduct_Price2,record.tables.detail[i].fields.SubProduct_Price3,record.tables.detail[i].fields.SubProduct_Price4];
		let subItems ="";
		for(let j=0; j<4;j++){
			subItems += '<tr data-repeat="" data-breakable="subItem' + j + '"><td>' + '&emsp;' + subProdCode[j] + '</td><td>' + subProdDesc[j]+ '</td><td>' + subProdQty[j] + '</td><td>'  + subProdPrice[j] + '</td></tr>';
			}
		this.after(subItems);           	
	}
});

You should also noctice that by default a dynamic table has widows and orphans properties set to 2 and thsis might affect how the table overflows. You should try setting these values to 0 in the properties of table. (Right-click on the table and click on Table…)

Hi Rod,

Thank you for the tips regarding the overflow and the data structure for the sub items. I was able to do the sub items part myself ;however regarding overflows, There are certain rules I need to follow regarding this;

  1. If the Details table would display the “item bundle” first, preceding items would be automatically printed on the next page.

  2. If the “item bundle” is the second data to be printed in the details table, It would still be displayed in the first page. However if the “item bundle” is the 3rd or 4th data, it would be displayed on the second page.

  3. If the details table doesn’t contain “item bundle” in its list, The items would all be printed in the first page (maximum would be 4 items, extra items would be printed in the 2nd page)

*Please take note that the second page has similar contents as the first page, the only difference would be the contents of the details table. (Just like a billing statement)

Thank you once again.

In the above script, you can use conditions and detail record indexes to decide when and where to insert the sub items in the dynamic table.

You may also control when the page break with the css page-break-before or page-break-after properties.

Hi Rod,

Is it possible to place the table contents after applying the page-break at the same position as the table contents of the first page? Another question, Is it possible that the only elements affected by the page break is the table only? Anything printed after the table should not be affected by the page break.

Is it possible to place the table contents after applying the page-break at the same position as the table contents of the first page?

This is possible but it all depends on your how the finshed template should look like. The most common option is to use a Master Page with a bigger top margin for overflowing pages. So add a new Master Page with bigger top margin, right-click on your Section and click on Sheet Configuration…, then untick the “Same for all positions” option and configure the middle sheets to use the new master Page.

Another question, Is it possible that the only elements affected by the page break is the table only? Anything printed after the table should not be affected by the page break.

This is also possible and again it all depends on the finished design. One common option is to put everything, that is underneath where you want the table to break and overflow, on a Master Page. So the Master page for the first page (assuming this is where the table is) should have a bottom margin big enough to accomodate the content that you need. In this way when the dynamic table reaches that bottom margin, it will automatically break and overflow to the next page and everything that is on the master page will not be affacted by the page break.

I suggest you take a look at the following tutorials:

https://learn.objectiflune.com/en-gb/pres-connect/designer/print/presentation

https://learn.objectiflune.com/en-gb/pres-connect/designer/print/sections

Hi Rod,

Thank you for the great tips and references that you’ve pointed out to me in this thread,

I will look into this and hopefully to resolve any remaining issues on my end here.

Thanks again.

Regards.