Skip to main content Link Search Menu Expand Document (external link)

@data-repeat : The Table Header Repetition Attribute

The data-repeat attribute controls whether table header rows (<thead>) automatically repeat at the top of each page when a table spans multiple pages in a PDF document. This is a critical feature for multi-page tables, ensuring that column headers remain visible and providing context for data on every page.


Summary

The data-repeat attribute enables or disables header repetition behavior for table headers, providing:

  • Automatic header repetition across multi-page tables (enabled by default)
  • Improved readability for long tables with consistent column identification
  • Professional formatting for reports and data-heavy documents
  • Flexible control over header display behavior

This attribute is essential for:

  • Multi-page reports with large datasets
  • Financial statements and accounting reports
  • Inventory and product listings
  • Transaction logs and audit trails
  • Any table that may span multiple pages

Default Behavior: Table headers (<thead>) repeat on each page by default. Use data-repeat="false" to disable this behavior.


Usage

The data-repeat attribute is applied to <thead> elements within tables:

<table style="width: 100%;">
    <thead data-repeat="true">
        <tr>
            <th>Column 1</th>
            <th>Column 2</th>
        </tr>
    </thead>
    <tbody>
        <!-- Many rows of data -->
    </tbody>
</table>

Basic Syntax

<!-- Enable header repetition (default behavior) -->
<thead data-repeat="true">
    <tr><th>Header</th></tr>
</thead>

<!-- Disable header repetition -->
<thead data-repeat="false">
    <tr><th>Header</th></tr>
</thead>

<!-- Omit attribute (defaults to true) -->
<thead>
    <tr><th>Header</th></tr>
</thead>

Supported Elements

The data-repeat attribute is only supported on the following element:

  • <thead> - The table header section element

Note: This attribute has no effect on <tbody>, <tfoot>, or other table elements. It is specifically designed for header repetition control.


Binding Values

Attribute Values

Value Description
true Headers repeat on each page (default behavior)
false Headers appear only once at the start of the table

Type

Type: boolean Default: true

Expression Support

The attribute accepts literal boolean values or binding expressions:

<!-- Literal value -->
<thead data-repeat="true">

<!-- Bound value -->
<thead data-repeat="">

<!-- Conditional based on table size -->
<thead data-repeat="">

Notes

Default Behavior

By default, table headers (<thead>) automatically repeat at the top of each page when a table spans multiple pages. This provides:

  • Consistent column identification across all pages
  • Better readability for long tables
  • Professional document formatting
  • Improved usability for printed documents

When to Disable Repetition

Consider setting data-repeat="false" when:

  • Table is guaranteed to fit on a single page
  • Headers are very tall and consume significant page space
  • Custom page breaking is implemented
  • Table structure changes mid-document
  • Headers contain images or complex layouts that impact performance

Performance Considerations

Header repetition has minimal performance impact:

  • Headers are rendered once and referenced on subsequent pages
  • Styling is cached for repeated headers
  • Memory usage is negligible even for complex headers

For very complex headers (images, nested tables), consider:

  • Simplifying header design
  • Using text-only headers for large datasets
  • Combining with data-cache-styles on data rows

Multi-Row Headers

When <thead> contains multiple rows, all rows repeat together:

<thead data-repeat="true">
    <tr>
        <th colspan="3">Main Header</th>
    </tr>
    <tr>
        <th>Column 1</th>
        <th>Column 2</th>
        <th>Column 3</th>
    </tr>
</thead>

Both header rows appear on each page.

Page Breaking Behavior

When a table spans pages:

  1. Current page fills with data rows
  2. New page begins
  3. If data-repeat="true", header rows are rendered at top of new page
  4. Data rows continue below the header
  5. Process repeats for all pages

Combining with Other Table Features

The data-repeat attribute works seamlessly with:

  • Column widths: Headers maintain consistent widths across pages
  • Styling: Header styles are preserved on all pages
  • Borders: Border rendering remains consistent
  • Background colors: Background colors repeat correctly
  • Data binding: Works with both static and dynamic tables

Accessibility and Usability

Repeating headers improve document usability by:

  • Eliminating need to reference earlier pages for column meaning
  • Providing context at a glance
  • Reducing errors in data interpretation
  • Improving scanning and searching in printed documents

Examples

1. Basic Repeating Header

Standard table with header repetition (default):

<table style="width: 100%; border-collapse: collapse;">
    <thead>
        <tr>
            <th style="border: 1pt solid black; padding: 8pt; background-color: #f0f0f0;">
                Name
            </th>
            <th style="border: 1pt solid black; padding: 8pt; background-color: #f0f0f0;">
                Email
            </th>
            <th style="border: 1pt solid black; padding: 8pt; background-color: #f0f0f0;">
                Phone
            </th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="border: 1pt solid black; padding: 8pt;"></td>
                <td style="border: 1pt solid black; padding: 8pt;"></td>
                <td style="border: 1pt solid black; padding: 8pt;"></td>
            </tr>
        </template>
    </tbody>
</table>

2. Disable Header Repetition

Single-page table without repetition:

<table style="width: 100%; border-collapse: collapse;">
    <thead data-repeat="false">
        <tr>
            <th style="border: 1pt solid black; padding: 8pt;">
                Item
            </th>
            <th style="border: 1pt solid black; padding: 8pt;">
                Description
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td style="border: 1pt solid black; padding: 8pt;">A</td>
            <td style="border: 1pt solid black; padding: 8pt;">First item</td>
        </tr>
        <tr>
            <td style="border: 1pt solid black; padding: 8pt;">B</td>
            <td style="border: 1pt solid black; padding: 8pt;">Second item</td>
        </tr>
    </tbody>
</table>

3. Styled Repeating Header

Professional styled header that repeats:

<table style="width: 100%; border-collapse: collapse;">
    <thead data-repeat="true">
        <tr style="background-color: #336699; color: white;">
            <th style="padding: 10pt; text-align: left;">Product Code</th>
            <th style="padding: 10pt; text-align: left;">Product Name</th>
            <th style="padding: 10pt; text-align: right;">Quantity</th>
            <th style="padding: 10pt; text-align: right;">Unit Price</th>
            <th style="padding: 10pt; text-align: right;">Total</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: right;">
                    
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: right;">
                    $
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: right;">
                    $
                </td>
            </tr>
        </template>
    </tbody>
</table>

4. Multi-Row Header

Complex header with two rows, both repeat:

<table style="width: 100%; border-collapse: collapse;">
    <thead data-repeat="true">
        <tr style="background-color: #2c3e50; color: white;">
            <th colspan="5" style="padding: 12pt; text-align: center; font-size: 14pt;">
                Quarterly Sales Report - Q1 2024
            </th>
        </tr>
        <tr style="background-color: #34495e; color: white;">
            <th style="padding: 8pt;">Region</th>
            <th style="padding: 8pt; text-align: right;">Jan</th>
            <th style="padding: 8pt; text-align: right;">Feb</th>
            <th style="padding: 8pt; text-align: right;">Mar</th>
            <th style="padding: 8pt; text-align: right;">Total</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: right;">
                    $
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: right;">
                    $
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: right;">
                    $
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: right; font-weight: bold;">
                    $
                </td>
            </tr>
        </template>
    </tbody>
</table>

5. Conditional Repetition Based on Data Size

Enable repetition only for large datasets:

<!-- Model: { items: [...], repeatHeaders: items.length > 25 } -->
<table style="width: 100%; border-collapse: collapse;">
    <thead data-repeat="">
        <tr style="background-color: #f0f0f0;">
            <th style="padding: 8pt; border: 1pt solid black;">ID</th>
            <th style="padding: 8pt; border: 1pt solid black;">Name</th>
            <th style="padding: 8pt; border: 1pt solid black;">Status</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="padding: 8pt; border: 1pt solid #ddd;"></td>
                <td style="padding: 8pt; border: 1pt solid #ddd;"></td>
                <td style="padding: 8pt; border: 1pt solid #ddd;"></td>
            </tr>
        </template>
    </tbody>
</table>

6. Invoice Line Items

Invoice table with repeating header:

<h1>Invoice #</h1>
<table style="width: 100%; border-collapse: collapse; margin-top: 20pt;">
    <thead data-repeat="true">
        <tr style="background-color: #e0e0e0; font-weight: bold;">
            <th style="padding: 10pt; border: 1pt solid black; text-align: left;">Description</th>
            <th style="padding: 10pt; border: 1pt solid black; text-align: right;">Qty</th>
            <th style="padding: 10pt; border: 1pt solid black; text-align: right;">Unit Price</th>
            <th style="padding: 10pt; border: 1pt solid black; text-align: right;">Total</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="padding: 8pt; border: 1pt solid #ddd;"></td>
                <td style="padding: 8pt; border: 1pt solid #ddd; text-align: right;"></td>
                <td style="padding: 8pt; border: 1pt solid #ddd; text-align: right;">$</td>
                <td style="padding: 8pt; border: 1pt solid #ddd; text-align: right; font-weight: bold;">
                    $
                </td>
            </tr>
        </template>
    </tbody>
    <tfoot>
        <tr style="font-weight: bold; background-color: #f9f9f9;">
            <td colspan="3" style="padding: 10pt; border: 1pt solid black; text-align: right;">
                Subtotal:
            </td>
            <td style="padding: 10pt; border: 1pt solid black; text-align: right;">
                $
            </td>
        </tr>
        <tr style="font-weight: bold; background-color: #f9f9f9;">
            <td colspan="3" style="padding: 10pt; border: 1pt solid black; text-align: right;">
                Tax (%):
            </td>
            <td style="padding: 10pt; border: 1pt solid black; text-align: right;">
                $
            </td>
        </tr>
        <tr style="font-weight: bold; font-size: 12pt; background-color: #e0e0e0;">
            <td colspan="3" style="padding: 10pt; border: 1pt solid black; text-align: right;">
                Total:
            </td>
            <td style="padding: 10pt; border: 1pt solid black; text-align: right;">
                $
            </td>
        </tr>
    </tfoot>
</table>

7. Transaction Log

Long transaction list with compact repeating header:

<h1>Transaction Log</h1>
<p>Account:  | Date Range:  - </p>

<table style="width: 100%; border-collapse: collapse; font-size: 9pt;">
    <thead data-repeat="true">
        <tr style="background-color: #336699; color: white;">
            <th style="padding: 6pt; border: 1pt solid black;">Date</th>
            <th style="padding: 6pt; border: 1pt solid black;">Transaction ID</th>
            <th style="padding: 6pt; border: 1pt solid black;">Description</th>
            <th style="padding: 6pt; border: 1pt solid black; text-align: right;">Debit</th>
            <th style="padding: 6pt; border: 1pt solid black; text-align: right;">Credit</th>
            <th style="padding: 6pt; border: 1pt solid black; text-align: right;">Balance</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="padding: 5pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 5pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 5pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 5pt; border-bottom: 1pt solid #ddd; text-align: right; color: red;">
                    
                </td>
                <td style="padding: 5pt; border-bottom: 1pt solid #ddd; text-align: right; color: green;">
                    
                </td>
                <td style="padding: 5pt; border-bottom: 1pt solid #ddd; text-align: right; font-weight: bold;">
                    $
                </td>
            </tr>
        </template>
    </tbody>
</table>

8. Inventory Report with Grouped Headers

Grouped column headers that repeat:

<table style="width: 100%; border-collapse: collapse;">
    <thead data-repeat="true">
        <tr style="background-color: #2c3e50; color: white;">
            <th rowspan="2" style="padding: 10pt; border: 1pt solid black; vertical-align: middle;">
                SKU
            </th>
            <th rowspan="2" style="padding: 10pt; border: 1pt solid black; vertical-align: middle;">
                Product
            </th>
            <th colspan="3" style="padding: 10pt; border: 1pt solid black; text-align: center;">
                Inventory
            </th>
        </tr>
        <tr style="background-color: #34495e; color: white;">
            <th style="padding: 8pt; border: 1pt solid black;">On Hand</th>
            <th style="padding: 8pt; border: 1pt solid black;">Committed</th>
            <th style="padding: 8pt; border: 1pt solid black;">Available</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="padding: 6pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 6pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 6pt; border-bottom: 1pt solid #ddd; text-align: right;">
                    
                </td>
                <td style="padding: 6pt; border-bottom: 1pt solid #ddd; text-align: right;">
                    
                </td>
                <td style="padding: 6pt; border-bottom: 1pt solid #ddd; text-align: right; font-weight: bold;">
                    
                </td>
            </tr>
        </template>
    </tbody>
</table>

9. Employee Directory

Multi-page directory with repeating styled header:

<style>
    .directory-header {
        background: linear-gradient(to bottom, #336699, #2c5577);
        color: white;
        font-weight: bold;
    }
</style>

<h1>Employee Directory</h1>

<table style="width: 100%; border-collapse: collapse;">
    <thead data-repeat="true" class="directory-header">
        <tr>
            <th style="padding: 10pt; text-align: left;">Name</th>
            <th style="padding: 10pt; text-align: left;">Department</th>
            <th style="padding: 10pt; text-align: left;">Title</th>
            <th style="padding: 10pt; text-align: left;">Email</th>
            <th style="padding: 10pt; text-align: left;">Phone</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr style="border-bottom: 1pt solid #ddd;">
                <td style="padding: 8pt;"> </td>
                <td style="padding: 8pt;"></td>
                <td style="padding: 8pt;"></td>
                <td style="padding: 8pt;"></td>
                <td style="padding: 8pt;"></td>
            </tr>
        </template>
    </tbody>
</table>

10. Product Catalog

Catalog with image-based header (repetition enabled):

<table style="width: 100%; border-collapse: collapse;">
    <thead data-repeat="true">
        <tr style="background-color: #f0f0f0;">
            <th style="padding: 10pt; width: 15%;">
                <img src="logo-small.png" style="height: 20pt;"/>
            </th>
            <th style="padding: 10pt; text-align: left;">Product Name</th>
            <th style="padding: 10pt; text-align: left;">Category</th>
            <th style="padding: 10pt; text-align: right;">Price</th>
            <th style="padding: 10pt; text-align: center;">Availability</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: center;">
                    <img src="" style="width: 40pt; height: 40pt;"/>
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: right; font-weight: bold;">
                    $
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: center;">
                    
                </td>
            </tr>
        </template>
    </tbody>
</table>

11. Audit Trail Report

Compliance report with repeating header:

<h1>System Audit Trail</h1>
<p>Generated:  | User: </p>

<table style="width: 100%; border-collapse: collapse; font-size: 8pt;">
    <thead data-repeat="true">
        <tr style="background-color: #dc3545; color: white;">
            <th style="padding: 6pt; border: 1pt solid black;">Timestamp</th>
            <th style="padding: 6pt; border: 1pt solid black;">User</th>
            <th style="padding: 6pt; border: 1pt solid black;">Action</th>
            <th style="padding: 6pt; border: 1pt solid black;">Resource</th>
            <th style="padding: 6pt; border: 1pt solid black;">Result</th>
            <th style="padding: 6pt; border: 1pt solid black;">IP Address</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="padding: 4pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 4pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 4pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 4pt; border-bottom: 1pt solid #ddd;"></td>
                <td style="padding: 4pt; border-bottom: 1pt solid #ddd;
                           color: ;">
                    
                </td>
                <td style="padding: 4pt; border-bottom: 1pt solid #ddd; font-family: monospace;">
                    
                </td>
            </tr>
        </template>
    </tbody>
</table>

12. Financial Statement

Financial data with multiple header levels:

<table style="width: 100%; border-collapse: collapse;">
    <thead data-repeat="true">
        <tr style="background-color: #2c3e50; color: white;">
            <th colspan="4" style="padding: 15pt; text-align: center; font-size: 14pt;">
                Income Statement - Year Ended December 31, 2023
            </th>
        </tr>
        <tr style="background-color: #34495e; color: white;">
            <th style="padding: 8pt; width: 10%; text-align: center;">Account</th>
            <th style="padding: 8pt; width: 50%; text-align: left;">Description</th>
            <th style="padding: 8pt; width: 20%; text-align: right;">Current Year</th>
            <th style="padding: 8pt; width: 20%; text-align: right;">Prior Year</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="padding: 6pt; border-bottom: 1pt solid #ddd; text-align: center;">
                    
                </td>
                <td style="padding: 6pt; border-bottom: 1pt solid #ddd;">
                    
                </td>
                <td style="padding: 6pt; border-bottom: 1pt solid #ddd; text-align: right;">
                    $
                </td>
                <td style="padding: 6pt; border-bottom: 1pt solid #ddd; text-align: right;">
                    $
                </td>
            </tr>
        </template>
    </tbody>
</table>

13. Order Fulfillment Report

Warehouse picking list with repeating header:

<table style="width: 100%; border-collapse: collapse;">
    <thead data-repeat="true">
        <tr style="background-color: #28a745; color: white;">
            <th style="padding: 10pt; text-align: center;">Pick</th>
            <th style="padding: 10pt; text-align: left;">Item Code</th>
            <th style="padding: 10pt; text-align: left;">Description</th>
            <th style="padding: 10pt; text-align: left;">Location</th>
            <th style="padding: 10pt; text-align: center;">Qty</th>
            <th style="padding: 10pt; text-align: center;">Picked</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: center;"></td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; font-family: monospace;">
                    
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd;">
                    
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; font-weight: bold;">
                    
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: center; font-size: 12pt;">
                    
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd;">
                    __________
                </td>
            </tr>
        </template>
    </tbody>
</table>

14. Event Schedule

Multi-day event schedule with repeating date headers:

<table style="width: 100%; border-collapse: collapse;">
    <thead data-repeat="true">
        <tr style="background-color: #6c757d; color: white;">
            <th style="padding: 10pt; width: 15%;">Time</th>
            <th style="padding: 10pt; width: 35%;">Session</th>
            <th style="padding: 10pt; width: 25%;">Speaker</th>
            <th style="padding: 10pt; width: 25%;">Location</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; font-weight: bold;">
                    
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd;">
                    
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd;">
                    
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd;">
                    
                </td>
            </tr>
        </template>
    </tbody>
</table>

15. Comparison Report

Side-by-side comparison with repeating headers:

<table style="width: 100%; border-collapse: collapse;">
    <thead data-repeat="true">
        <tr style="background-color: #17a2b8; color: white;">
            <th style="padding: 10pt; text-align: left;">Feature</th>
            <th style="padding: 10pt; text-align: center;">Product A</th>
            <th style="padding: 10pt; text-align: center;">Product B</th>
            <th style="padding: 10pt; text-align: center;">Product C</th>
        </tr>
    </thead>
    <tbody>
        <template data-bind="">
            <tr>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; font-weight: bold;">
                    
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: center;">
                    
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: center;">
                    
                </td>
                <td style="padding: 8pt; border-bottom: 1pt solid #ddd; text-align: center;">
                    
                </td>
            </tr>
        </template>
    </tbody>
</table>

See Also