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

CrossTab with fixed width possible?

4 Answers 233 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tobias
Top achievements
Rank 1
Tobias asked on 04 Nov 2015, 01:10 PM

Hello,

is it possible to set a CrossTab to a fixed width​? The first column (underneath the corner) and the last column (the total column) should also get a fixed width but all columns between them should became the same width wich is calculated by "<remaining space> divided by <number-of-columns>".

I know it could be possible that the content of the columns is truncated because the columns are getting to small but for this case I would dynamically downsize the font size.

Greetings from Germany,

Tobias

4 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 06 Nov 2015, 04:26 PM
Hello Tobias,

The Crosstab item does not provide an auto-size or a fixed width out-of-the-box.
You can create the whole Crosstab item programmatically in your application and set its column widths according to custom logic based on your data. Note that this is not a trivial solution and you will need the help of the Reporting API Reference.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Tobias
Top achievements
Rank 1
answered on 10 Nov 2015, 08:52 PM

Hello Nasko,

thank you for your reponse. I want to create the Crosstab programmatically but where? I am looking for an event like "data source bound" where I can start analyzing the bound data to create the column widths programmatically.

Regards,

Tobias

0
Tobias
Top achievements
Rank 1
answered on 11 Nov 2015, 08:48 AM

Hello Nasko,

I got it! I have to use the ItemDataBinding event of the cross table. At this point I can calculate with the data and manipulate the crosstable definition and all of the child items.

I have attached my result.

Regards,

Tobias

0
Tobias
Top achievements
Rank 1
answered on 20 Nov 2015, 11:11 PM

Hello,

it's me again. I though I got it but I get it only to work in the preview in the designer but not if I render the report as PDF. If I programmatically render a report and want to set the bound data from outside I can only use the DataSource property of the Report class. Am I right? I am rendering the report as follows:

01.var reportModel = new MainReportModel()
02.{
03.    Orders = Report1._Orders()
04.};
05. 
06.ObjectDataSource objectDataSource = new ObjectDataSource();
07.objectDataSource.DataSource = reportModel;
08. 
09.var report = new Report1();
10.report.DataSource = objectDataSource;
11. 
12.InstanceReportSource instanceReportSource = new InstanceReportSource();
13.instanceReportSource.ReportDocument = report;
14. 
15.ReportProcessor reportProcessor = new ReportProcessor();
16.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, null);
17. 
18.File.WriteAllBytes("test.pdf", renderingResult.DocumentBytes);

For design time I added a ObjectDataSource of type Order. So I can use the expression designer for example. For render time I added a binding to my crosstable to bind DataSource to the Orders property of MainReportModel. How can I get the bound order list in the ItemDataBinding event to do my calculation of the column width?

Regards,

Tobias

Tags
General Discussions
Asked by
Tobias
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Tobias
Top achievements
Rank 1
Share this question
or