This is a migrated thread and some comments may be shown as answers.

Nested Tables makes page breaks in PDF

3 Answers 401 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Raphael
Top achievements
Rank 1
Raphael asked on 10 Feb 2012, 03:12 PM

Hello everyone,
I have to create a report with in total 4 nested tables. We'll do the example with only 2 tables for easier comprehension. 
Assume we have an array with Orders, and in this table is an array with Products. So for each Order we have several Products. 

I made a TelerikTable which is bound on the Orders. The first line is the table headers. Each Order has 3 lines:
- 1: specific information about the Order (id Order, ...)
- 2: A merged line with another table in it, bound on the Products array.
- 3: The total of all Products of that Order.
For better / clear comprehension, look at the NestedTable.jpg (attached file).

Let’s export that list in PDF format:
Now the problem is that some Orders have a lot of Products: for example 200 Products. An order doesn't necessarily begin at the beginning of the A4 page (it can be in the middle). So the array of Products of the second Order doesn’t fit on the first page, and it makes automatically a page break (because its 1 merged line of the main table?).

For better / clear comprehension, look at the ProblemNestedTable.jpg (attached file).

KeepTogether parameter is everywhere to false.

I don’t want that page break, but fragment the nested table (Products).

Is there a way that there is a “Keep Table Line Together = False”? Or I may be completely wrong with my table structure? Maybe there is another option instead of nested tables?

Thanks a lot :)

Raphael

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 11 Feb 2012, 04:16 PM
Hello Raphael,

Your assumption is correct. This issue occurs because of the nested table which is inside a row of the parent table and it cannot break, so naturally it begins on a new page. With this layout (nested tables) this cannot be avoided.

We would suggest to upgrade to our latest version (if you're using older) and to change the layout of the application so it doesn't use nested tables. Instead, use nested groups (you can keep the most inner table) and transform the outer three tables into groups.

All the best,
Steve
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Raphael
Top achievements
Rank 1
answered on 29 Feb 2012, 11:30 AM
Hello Steve,
Thank you for your answer.
I'm fairly new to Telerik Reporting, so I took a look at these groups. I based my instruction on:
Grouping Data
Reporting Tutorial (p 60-65)
How-to create groups

But I have to miss something: How are groups databound, aren't they?


For the main table I used the binding:
  • '=Fields.Orders'
And in the nested table I used the binding:
  • '=Fields.Products' (which were Fields.Orders.Products)


You said that I have to transform the tables into groups, so this is my new structure:
--------------------------------------------
...
--------------------------------------------
Group1 Header
--------------------------------------------
Report Details
--------------------------------------------
Group1 Footer
--------------------------------------------
...
--------------------------------------------

In 'Group1 Header' I hav now labels which are bound on '=Fields.Id' (in Orders).
And in 'Report Details' I have labels (or a table, which doesn't really matter) bound on '=Fields.Id', '=Fields.Quantity', ... (in Products).


But none of these work, because those are Arrays. 
How do I use nested groups?


Thank you,
Raphael
0
Elian
Telerik team
answered on 02 Mar 2012, 12:40 PM
Hello Raphael,

When you work with report groups your incoming data must be flat (one array). Let's say you have this:
Name Age
A 10
B 20
C 10
20
E 10

If you use grouping on report level, you will have the data represented to you like this:
Age = 10
A
C
E
Age = 20
B
D

This is what the grouping does, you still have the same flat data but it is grouped on certain criteria.

In case you have your input data in the form of nested collections, like this:
Order1
Product1, Product2, Product3
Order2
Product1, Product2, Product3 
Order3
Product1, Product2, Product3 

That means that you have your data already grouped. If that's the case, then you can Bind the Report.DataSource to the Orders[ ] collection and then put a table inside the detail section. This table's DataSource would be the Products[ ] collection. This can be achieved using Bindings and the ReportItem.DataObject which gives you the current data row. I also have attached a sample project showing this approach.

All the best,
Elian
the Telerik team
NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.
Tags
General Discussions
Asked by
Raphael
Top achievements
Rank 1
Answers by
Steve
Telerik team
Raphael
Top achievements
Rank 1
Elian
Telerik team
Share this question
or