4D Blog

Home Product 4D Write Pro: Carry Over Rows are Available!

4D Write Pro: Carry Over Rows are Available!

October 14, 2022

Product

Using tables in 4D Write Pro documents is more frequent, especially since it is possible to associate a datasource to them, which automatically feeds their rows!

As the number of rows gets more prominent, it is common for these tables to be automatically split into several parts to allow for a page or column break. In this situation, it is sometimes convenient to insert (automatically!) a “subtotal” line at the bottom of each part of the respective tables. Yes, that’s right, this is possible in 4D v19 R7 ?

Demo database

A picture is worth a thousand words.

A picture always beats a long explanation. Here is what we want to obtain:

As you can see, each table part – except the last one – contains an extra row used here to display a subtotal.

This is often necessary, sometimes even legally required, when editing long invoices, for example.

ONE ROW in THE template, AS MANY AS necessary IN THE final document

As mentioned in the introduction, this functionality is available for all tables. Still, it is only considered when tables are associated with a datasource (a collection or a selection of entities). Once this property is activated, the row immediately following the “repeated” row will become the carry-over row.

blank

The activation of this property can be done via the interface…

In both interfaces (toolbar and sidebar), the table menu (  ) contains a new item, “Bottom carry over row.”

 

blankblank

… Or by programming

WP SET ATTRIBUTES($table ; wk bottom carry over row ; True | False)

DUPLICATED OR NOT?

It is essential to understand that this row, unique in the template, will be duplicated as often as necessary once the document is evaluated.

Note that this will not be necessary if the table “fits” in a single block. In this case, the carry-over row will not be represented in the evaluated document.

Otherwise, it will be inserted at the end of every block except the last one. Logically, the last part of the split table should not contain a subtotal but a “Grand Total.” This is why, in the template, the carry-over row is not the last one but is followed by the last rows of the table.

THE CONTENT OF THE CARRY-OVER ROWS

How should the content of the cells in this carry-over row be defined?

As you may have guessed, a new attribute is born: previousItems, which can be used as follow:

This.previousItems.sum("price")

This.previousItems returns, depending on the table datasource, either a collection or a selection of entities.

This set contains all the items that have already been evaluated on the current page and the previous ones. You can apply all available functions (min/max/sum/etc.) for collections or entity selections!

Note that if This.previousItems is mainly designed to be used in carry-over rows, its use is not limited to this particular context. It can be used anywhere in the table (except headers) with different values in each context.

Conclusion

This new property makes it possible to get rid of complex code and enrich tables during automatic page jumps.
Enjoy creating lovely templates and avoid complex coding! And as always, your feedback is much appreciated. Join the discussion on the 4D Forum.

More information about carry over rows can be read in the documentation.

Discuss

Tags 4D Write Pro, Table, v19 R7, v20, Word processor

Latest related posts

  • July 18, 2025

    Embed deployment license automatically into your applications

  • July 17, 2025

    New Class to Perform UDP Communications

  • July 17, 2025

    Managing Calendar Events with Microsoft 365 or Google in 4D: Create, Update, Delete

Roland Lannuzel
Roland Lannuzel
• Product Owner & 4D Expert •After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R9 20 R10 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R9 20 R10 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy