[reportlab-users] Is there a way to prevent table split between particular rows?

1,470 views
Skip to first unread message

Lele Gaifax

unread,
Feb 19, 2016, 4:08:31 PM2/19/16
to reportl...@reportlab.com
Hi,

I tried to find a way to prevent a split between particular rows in a Table:
the table in question is "grouped" and at the end of each group there is a
summary row, that I would like to avoid being orphaned on the next page on its
own.

I found a "rowSplitRange" argument on the Table ctor, that seems able to
influence the algorithm, but I failed to understand its logic, and it is not
even mentioned in the docs.

Thank you in advance for any hint!

ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
le...@metapensiero.it | -- Fortunato Depero, 1929.

_______________________________________________
reportlab-users mailing list
reportl...@lists2.reportlab.com
https://pairlist2.pair.net/mailman/listinfo/reportlab-users

Robin Becker

unread,
Feb 19, 2016, 5:40:17 PM2/19/16
to reportlab-users
Hi Lele,


The docs need to be extended mea cupla :(

The rowSplitRange is intended to prevent splitting near the top of the
table or to near to the end. There is only one allowed range = lo,hi
and splitting is only allowed if the lo<=splitpoint <=hi. I suppose
this could be extended to a more general list of allowed split ranges,
but that's not available right now.

If that's required I would have to do some extra thinking.

--
Robin Becker

Robin Becker

unread,
Feb 19, 2016, 5:40:53 PM2/19/16
to reportlab-users
PS cupla should be culpa :)

Lele Gaifax

unread,
Feb 19, 2016, 6:19:23 PM2/19/16
to reportl...@reportlab.com
Robin Becker <ro...@reportlab.com> writes:

> The docs need to be extended mea cupla :(

Don't worry, I know what it means to keep that in sync!

> The rowSplitRange is intended to prevent splitting near the top of the
> table or to near to the end. There is only one allowed range = lo,hi
> and splitting is only allowed if the lo<=splitpoint <=hi. I suppose
> this could be extended to a more general list of allowed split ranges,
> but that's not available right now.
>
> If that's required I would have to do some extra thinking.

Well, the project I'm developing is not that important: should the customer
raise her eyebrows, I will try to rearrange the printout using multiple
tables, one for each group, wrapping each table within a KeepTogether element.

Anyway, for my need, it would maybe be more natural to express the constraint
within the TableStyle, something like

...
('KEEPTOGETHER', (0, 2), (-1, 3)),
...

to mean that preferably a split should not happen between row 2 and 3. That
could cover even the split-by-column case.

What do you think?

Thank you,

Robin Becker

unread,
Feb 20, 2016, 3:43:08 AM2/20/16
to reportlab-users
Yes that would do it. Probably better than the existing hack
mechanism. Chances of ever splitting by columns recede.

--
Robin Becker

Axel P. Kielhorn

unread,
Feb 20, 2016, 4:14:58 AM2/20/16
to reportl...@lists2.reportlab.com

> Am 20.02.2016 um 00:19 schrieb Lele Gaifax <le...@metapensiero.it>:
>
> Robin Becker <ro...@reportlab.com> writes:
>
>> The docs need to be extended mea cupla :(
>
> Don't worry, I know what it means to keep that in sync!
>
>> The rowSplitRange is intended to prevent splitting near the top of the
>> table or to near to the end. There is only one allowed range = lo,hi
>> and splitting is only allowed if the lo<=splitpoint <=hi. I suppose
>> this could be extended to a more general list of allowed split ranges,
>> but that's not available right now.
>>
>> If that's required I would have to do some extra thinking.
>
> Well, the project I'm developing is not that important: should the customer
> raise her eyebrows, I will try to rearrange the printout using multiple
> tables, one for each group, wrapping each table within a KeepTogether element.
>
> Anyway, for my need, it would maybe be more natural to express the constraint
> within the TableStyle, something like
>
> ...
> ('KEEPTOGETHER', (0, 2), (-1, 3)),
> ...
>
> to mean that preferably a split should not happen between row 2 and 3. That
> could cover even the split-by-column case.
>
> What do you think?

This sounds like a good idea.
I create a table where two rows are grouped together.
(First row describes start condition, second row end condition.)
They alternate background color (2 rows white, 2 rows gray)
Sometimes the table is split inside a pair of rows which looks unprofessional:-)

In my case it would be
('KEEPTOGETHER', (0, 1), (2, 3), ...)

Geetings
Axel

Robin Becker

unread,
Feb 24, 2016, 5:20:36 AM2/24/16
to reportlab-users
Hi Lele & Axel,

.........
>> What do you think?
>
> This sounds like a good idea.
> I create a table where two rows are grouped together.
> (First row describes start condition, second row end condition.)
> They alternate background color (2 rows white, 2 rows gray)
> Sometimes the table is split inside a pair of rows which looks unprofessional:-)
>
> In my case it would be
> ('KEEPTOGETHER', (0, 1), (2, 3), ...)
.......


I just don't like the KEEPTOGETHER tag since that is already used elsewhere in
Paragraph styles and is in fact not totally binding. I think we should use
'NOSPLIT' and it seems we already did! I had completely forgotten about this
command.


Can you try adding

('NOSPLIT', (0, 2), (-1, 3))

or

('NOSPLIT', (0, 1), (2, 3))

to see if this actually works for you?
--
Robin Becker

Lele Gaifax

unread,
Feb 24, 2016, 5:42:56 AM2/24/16
to reportl...@reportlab.com
Robin Becker <ro...@reportlab.com> writes:

> I think we should use 'NOSPLIT' and it seems we already did! I had
> completely forgotten about this command.
>

> Can you try adding to see if this actually works for you?

Wow Robin, that's a nice and great surprise indeed!

It seems doing exactly what I needed; I'll do some more tests, but the
printout which presented the problem looks correct!

Thank you a lot,
bye, lele.


--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
le...@metapensiero.it | -- Fortunato Depero, 1929.

_______________________________________________

Robin Becker

unread,
Feb 24, 2016, 5:50:37 AM2/24/16
to reportlab-users
On 24/02/2016 10:42, Lele Gaifax wrote:
> Robin Becker <ro...@reportlab.com> writes:
>
>> I think we should use 'NOSPLIT' and it seems we already did! I had
>> completely forgotten about this command.
>>
>> Can you try adding to see if this actually works for you?
>
> Wow Robin, that's a nice and great surprise indeed!
>
> It seems doing exactly what I needed; I'll do some more tests, but the
> printout which presented the problem looks correct!
>
> Thank you a lot,
> bye, lele.
>
Great,

I'm adding some documentation.
--
Robin Becker
Reply all
Reply to author
Forward
0 new messages