4D Blog

Home Product 4D Write Pro: Manage Empty Datasources!

4D Write Pro: Manage Empty Datasources!

July 18, 2024

Product

Since the tables in 4D Write Pro can be populated by datasources, numerous functions have been added to personalize them as much as possible. These include formulas linked to datasources, break rows, bottom carry over rows, etc.

4D 20 R6 refines table behavior with a new attribute: wk empty datasource. This attribute allows you to define how tables render when their linked datasource is empty, providing greater control over document presentation.

HDI: Manage Empty Datasources!

A new table attribute: wk empty datasource

This new attribute defines a table’s behavior when its associated datasource is empty (each table can have different settings). This attribute is only considered if a datasource is associated with the table. If this is not the case, it will be ignored. Similarly, it will only be considered when the datasource is empty.

Here are your options:

  • Show data row (default)
  • Hide the data row
  • Hide the entire table
  • Display a placeholder row

If a datasource is empty, you may still want to keep (display) the header rows (up to 5 possible rows, as a reminder) and the rows that follow the data row (the data row being the row repeated for each element in the datasource). If this option is selected, neither the data row nor the breaks (if any) will be displayed.

WP SET ATTRIBUTES($table; wk empty datasource; wk hide data row)

In other cases, a table may no longer be interesting if its datasource is empty. In this case, the solution is not to display the table.

WP SET ATTRIBUTES($table; wk empty datasource; wk hide table)

At least, when the datasource is empty, you may want to display a placeholder row specially designed for this purpose instead of the regular data row.

WP SET ATTRIBUTES($table; wk empty datasource; wk show placeholder row)

For completeness, there is a fourth option: wk show data row. This value—which is actually the default value—will be used if you reset the attribute with the WP RESET ATTRIBUTES command.

WP SET ATTRIBUTES($table; wk empty datasource; wk show data row)
 // is equivalent to
WP RESET ATTRIBUTES($table; wk empty datasource)

Import/export

Whatever the value chosen for this new option, it will be applied when exporting, regardless of the format selected.

Docx, HTML, SVG, PDF… in all cases, the tables will be represented (or not) depending on the chosen options.

TABLE WIZARD IMPROVEMENTS

Do you remember the table wizard? If not, you may never have used it. Follow the following link to learn more about it!

So, the table wizard has not been forgotten. Thanks to a new item in the interface, you can define this setting!

If you choose “Show placeholder row,” the wizard will automatically add a new row labeled [D’] for you!

The appearance of the placeholder row can be defined in the themes (inside the resources folder) JSON files thanks to a new “placeholder” entry.

"placeholder": {
    "color": "#202020",
    "fontSize": "10pt",
    "backgroundColor": "yellow"
}

The same goes for the formulas that can be inserted by a contextual menu. A new entry, placeholderFormulas, has been defined in the “templates” JSON files inside the resources folder.

"placeholderFormulas": [
    {
        "label": "Count",
        "source": "This.tableData.count()"
    },
    {
        "label": "Current date",
        "source": "Current date"
    }
]

Conclusion

With this new feature, 4D Write Pro empowers you to create even more dynamic and informative documents. Don’t hesitate to share your thoughts and experiences on the 4D forum!

Discuss

Tags 20 R6, 21, 4D Write Pro, Table, Word processor

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

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 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio 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 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio 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