Split Detail Table Based On Row/Cell Value

Hi,

I have a detail table that handles multi paged data. Issue is when I set the section borders (header/footer) to cut the detail table at a certain word/row (Carried Forward i.e. C/F), this works fine for multi page records. However some single page records need more space for the table. If I reduce the border then that breaks the break for the multi paged records.

What I would like to know is if there is a way to break a detail table onto another page if a cell/column contains a certain string.

Regards,

S

Try the script and CSS below. Change the selector to match the table rows in the tbody section of your table. The script iterates over the rows and uses that index to retrieve the respective values from the detail table. In case a match is found it will add a CSS class to the respective row (this). The class sets the page-break-after property to always. This will force a page break after this row.

Add the respective CSS rule to one of the stylesheet files (for example context_print_styles.css)

CSS rule

.after {
    page-break-after: always;
}

Script

Selector: #table_1 tbody tr
results.each(function(index) {
    var somestring = record.tables['detail'][index].fields.ItemNumber;
    if( somestring == 'hello world') {
        this.addClass('after');
    }   
});

Hope this is of some help,

Erik

Thanks Erik, works wonders.

Regards,

S

Good to hear!

what if i only want the page break being call when i hit second occurrence of “Hello World”?

Hi John,

I would just slip in a counter variable and add another if statement.

var count = 0;
results.each(function(index) {
    var somestring = record.tables['detail'][index].fields.ItemNumber;
    if( somestring == 'hello world') {
        count += 1;
        if(count == 2){
              this.addClass('after');
        }
    }   
});

Hi Erik, I need to do something similar, split the table when the detail lines are equal to 12, can you help me with this?

How about:

#table tbody tr:nth-child(12n) {
    page-break-after: always;
}

Assumes your detail table has an ID set “table”.

thank you very much Erik !