Forum


Replies: 1   Views: 2308
How does the cantsplit property of table rows work?
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by dev@ram  · 18-12-2018 - 14:12

I want certain rows of the table to stay together and not get split across pages. I tried to apply the cantSplit =1 for the rows but it does not seem to work

$docx->addTable($data['rows'],$tableStyles, $tableRowProps);

The content of $tableRowProps is

Array
(
    [0] => Array
        (
            [tableHeader] => 1
        )

    [1] => Array
        (
            [cantSplit] => 1
        )

    [2] => Array
        (
            [cantSplit] => 1
        )

    [3] => Array
        (
            [cantSplit] => 1
        )

    [4] => Array
        (
            [cantSplit] => 1
        )

    [6] => Array
        (
            [cantSplit] => 1
        )

    [7] => Array
        (
            [cantSplit] => 1
        )

    [9] => Array
        (
            [cantSplit] => 1
        )

    [10] => Array
        (
            [cantSplit] => 1
        )

    [11] => Array
        (
            [cantSplit] => 1
        )

    [12] => Array
        (
            [cantSplit] => 1
        )

    [13] => Array
        (
            [cantSplit] => 1
        )

    [14] => Array
        (
            [cantSplit] => 1
        )

    [15] => Array
        (
            [cantSplit] => 1
        )

    [16] => Array
        (
            [cantSplit] => 1
        )

    [17] => Array
        (
            [cantSplit] => 1
        )

    [18] => Array
        (
            [cantSplit] => 1
        )

    [20] => Array
        (
            [cantSplit] => 1
        )

    [21] => Array
        (
            [cantSplit] => 1
        )

    [22] => Array
        (
            [cantSplit] => 1
        )

    [23] => Array
        (
            [cantSplit] => 1
        )

    [24] => Array
        (
            [cantSplit] => 1
        )

    [25] => Array
        (
            [cantSplit] => 1
        )

    [27] => Array
        (
            [cantSplit] => 1
        )

    [28] => Array
        (
            [cantSplit] => 1
        )

    [29] => Array
        (
            [cantSplit] => 1
        )

    [30] => Array
        (
            [cantSplit] => 1
        )

    [31] => Array
        (
            [cantSplit] => 1
        )

)

But the table still splits(at 27th row). So I'm not sure what is happening.

Please see attached screenshot of doc generated.

https://drive.google.com/open?id=1aNvJqqtYT1647z3CRgRomyZ3Our10ukT

Basically what I'm trying to do is to get the content with the blue background and all the rows immediately below it with the white background(group them) to be in the same page(avoid the table splitting them into different pages). I tried cantSplit=0 for the last white row(with all others(cantSplit=1) but that didnt work so I put everything to cantSplit =1 . That did'nt work either. So how does it work ??

Any help is highly appreciated.

Posted by admin  · 18-12-2018 - 16:12

Hello,

The cantSplit option set 'Allow row to break across pages' as false, so if the row content doesn't fit in a page, the whole row moves to the next page.
If you need to keep rows on the same page, then you need to use keepNext and keepLines options available in paragraph contents and paragraph styles.

You can read more about this MS Word behavior on the following pages:

https://word.tips.net/T000865_Keeping_Table_Rows_Together.html

https://answers.microsoft.com/en-us/msoffice/forum/all/how-do-i-keep-table-rows-together/4d9b5f24-933f-49e1-825e-eabacd2b86b1

https://word.tips.net/T000864_Keeping_Tables_on_One_Page.html

These samples illustrate how to do it using MS Word, but can set the same options using phpdocx.

Regards.