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

How to center a rotated table horizotally

6 Answers 331 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Patrick asked on 25 Jan 2013, 10:27 AM
Hello,
in a report I have a table which has a rotated layout: headers at the left and data in columns.
How can I center the table horizontally in the page?
Patrick

6 Answers, 1 is accepted

Sort by
0
Steven
Top achievements
Rank 1
answered on 25 Jan 2013, 02:19 PM
Rather then setting the Rows TableGroup to be the details, just set the Columns TableGroup to have the null Grouping (details) which will cause the table to iterate its rows horizontally.

The Tables Rows and Columns are the same type (TableGroup), and as the table processes it just iterates over the item with a null grouping (the details TableGroup)


                   [Static Column] [Detail Column] [Static Column]
[Static Row]
[Static Row]
[Static Row]
[Static Row]


If you need the table to loop horizontally and vertically then you'll need to use a crosstable.
But if you only need to loop in one axis, then any logic you apply to the ROWS can also be applied to the COLUMNS.

Just select a Table cell (Textbox) and then the menu item Telerik => Reporting -> Group Explorer.  Within the Group Explorer ensure you're viewing the extended view.


-- Sorry read your post wrong,  
You may be able to apply it within the Tables ItemDataBound event.   At this point the table is populated and the width is property calculated.  You may be able to overwrite the location at this point.   I don't think you can overwrite a single axis so you'll have to set the location with

var table = (Telerik.Reporting.Processing.Table)sender;
double left = (this.Report.Width.Value - table.Width.Value) / 2;
table.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(left), table.Location.Y);

0
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
answered on 25 Jan 2013, 04:16 PM
Steven,
thank you for your answer, but I though there was a solution without writing code behind, just using the properties of the table.
Does somebody has such a solution?
Patrick
0
Hadib Ahmabi
Top achievements
Rank 1
answered on 28 Jan 2013, 03:20 PM
I am not even sure that you can center the table horizontally. Even in the processing event you will get the size as per definition. 
0
Steven
Top achievements
Rank 1
answered on 29 Jan 2013, 12:34 AM
In the ItemDataBound event, you get a processed table that is fully populated and you can iterate the columns to calculated the table width before it renders.    For Row Height you have to use reflection, but I believe Column Width has a getter.   If the columns are not properly calculated, then you can iterate the cells and accumulate the max of each ColumnIndex.

I've created a couple extension methods to expand/shrink/collapse columns in the ItemDataBound event, but adjusting a single columns width requires me to update every tableCell.Item Width in that column, the TableColumn's Width and the Table's Width.

You should then be able to adjust its location accordingly and in theory should be able to center both horizontally and vertically.
0
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
answered on 05 Feb 2013, 07:17 AM
Hello,
nobody at Telerik has a simple answer, without writing code behind?
Something like an HorizontalAlignment property or the like?
Is it something planned for a near future version?
Patrick
0
Steve
Telerik team
answered on 07 Feb 2013, 03:40 PM
Hi Patrick,

There is no out of the box way to center any report item that grows horizontally. The approach provided by Steven is the only way to accomplish this for the time being.

Regards,
Steve
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Tags
General Discussions
Asked by
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Steven
Top achievements
Rank 1
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Hadib Ahmabi
Top achievements
Rank 1
Steve
Telerik team
Share this question
or