We often work on cases where an item position is not kept together on one page even though the “KeepTogether” property is set to “True” on the Details Group. The reason is that the Details Group is not treated by the SSRS as a regular group used for grouping data. Hence, a possible solution to this issue is to add a parent group around the Details Group.
Here are the steps that helped to achieve it in the standard SalesInvoice report:
1. Open the SalesInvoiceReport project for editing in Visual Studio (detailed steps can be found here).
2. In the Model Editor, expand the Designs node, right click on the Report design and select Edit Using Designer…
3. In the Designer editor, click inside the first tablix in the report layout (table16) and toggle the grouping pane to Advanced mode view by right clicking the down arrow on the right side of the pane and selecting Advance mode.
4. In the grouping pane, right click on the details group tables16_Details_Group and select Add Group/Parent Group.
5. In the Tablix group dialog box, select [ItemId] for Group by and press OK.
This will add a grouping column in front of the tablix and the group Group1 will appear above the Details Group in the grouping pane.
6. Right click on top of the grouping column in the tablix and select Delete Columns.
7. In the Delete Columns dialog box, select Delete columns only and press OK.
8. In the grouping pane, set the properties for both static header rows as follows:
9. Right click on the created group Group1 and select Group Properties.
10. In the Group Properties form, click on Sorting and on the Sort by line in the Change sorting options pane, press Delete and OK.
This will allow to preserve the original sorting order of the order lines as they appear on the form.
11. Before saving and deploying the report, adjust the report width to its previous width as it was increased automatically when the grouping column was added to the tablix in step 5.
Set the width of the Rectangle InvoiceItemsRectangle and of the body to the value that does not exceed page width – left margin – right margin as otherwise each page might be split into two pages.
12. Save and deploy the report.
–author: Jolanta Malkowska