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

Report and Table Datasource...

2 Answers 495 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jess Askey
Top achievements
Rank 2
Jess Askey asked on 26 Apr 2011, 08:25 AM
Hello...

I am attempting to duplicate an Excel report that has a two row header with column spans within those two rows. All the header text is static.

In the detail, have have some rowspans and a few static text cells, the details ends up being 4 rows.

From reading through the docs, it looks as if I need to use a table to accomplish the two row header (I want this header to repeat at the top of each page as well).

I am also binding to an object data source. I have created a wrapper class to simplify binding. It is very similar to the docs using the Car and Cars classes. However, I just want bind my report to a System.Collections.Generic.List<Car> rather than making an unneeded Cars class. However, I run into problems getting my report and table to bind properly so that I can simply show the 4 row detail (remember 4 rows per bound item, this is due to horrible formatting in the original report, sort of a summary table approach for each item).

So, given that I have 8 items bound and lets say only one item fit on a page (due to the large multirow header), I would end up with 8 Pages. Table header on each page, followed by the bound report items (textboxes only) for the current item.

I hope that is a clear explanation of what Im trying to do... now for my questions. :-)

1. How do I set up DataBinding for the report and Table? I tried binding directly to the equivalent Car class and also setting that data source to the table, but that didn't work at all. It seems I have to create an equivalent Cars class to wrap the list only? Seems unneeded tho?

2. When I drag a table onto my report detail I get the standard 3 column table header and table detail. Once I started adding rows and columnns and then merging them, the table looked great but once I previewed, I started getting missing cells. Is there some sort of trick to getting cells added and merged so that they stay in the header? Things really started to get weird in the header when I added multiple rows, in the end, the only header cells that showed up were in the original header row, the row I added above refused to render. If I merged any cells to the top row of the header, the refused to render too.

I attached a screenshot of the report I am trying to make so you can see the messiness. The header is highlighted in Yellow and the bottom 4 rows are repeated *for each* bound item. In the photo, there are two bound items that would be shown in the 8 rows below the header. I had to blur it to protect the content somewhat, but it is still good for layout purposes.

thank you

ja

Im using Reporting Q3 2010 and winforms + ASP in .NET 3.5

2 Answers, 1 is accepted

Sort by
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 28 Apr 2011, 04:13 PM
It is kind of hard for me to explain why you cannot bind directly to the Car class, if you do not realize why you can't. It only contains properties and no data, so what would be the purpose of using it as data source? For the sake of test try setting it as data source for a GridView or any other data bound control and the result would be the same i.e. nothing specific about the ObjectDataSource component in reporting. To summarize you should either have a method which returns a collection or the class itself should implement a collection and populate the data in a default constructor. Otherwise it is pointless to bind to such a class, as there would not be a way to initialize and fill it with data.
I cannot be sure about the second problem and it would be best to provide the report in question. This is programming after all and words are no substitute for code.

Cheers!
0
Jess Askey
Top achievements
Rank 2
answered on 28 Apr 2011, 05:03 PM
Hi Massimiliano ...

Thank you for your reply. I do understand why I can't 'bind' to the Car class after all, it is just a definition and not an instance until it is part of a collection. I guess I was mostly confused by the ability to bind the report and the table and I was not sure how to do that via the interface by setting the DataSource of the Table at designtime to be the DataSource of the Report. However, in the past few days, I have been working on this more and more and I am happy to report, that I have this working now, even the very messy double-row header. Here is what I did...

On the binding:

I went away from doing anything to the Report and Table DataSource at designtime and did it all at runtime. It was quite simple...

table1.DataSource = _cars;
this.DataSource = _cars;

I sort of expected this to give me cross-tabbed (aka 3 items in _cars would give me 9 rows) but it didn't since my table just sits in the details section.

On the funky headers and detail sections:

I went away from using the Table header for my double-row merged header cells. It seem that with the designer and the various TableGroups that the designer creates along the way, that things were getting really ugly in the nesting of the ColumnGroups and RowGroups and in the end, the report just wouldn't run. I would get errors telling me that I had duplicate TableGroup names and when looking at the designer.cs file, it was complete spaghetti code due to the sheer number of rows and columns (2 x18 + merges) in the header. So, my solution was simply to take the header out of the Table header and put it in the page header as a grid of textboxes statically placed and sized to look like a table grid. Since my resulting report would only fit the header and 1 data item (in the table of the detail section) per page, using the report header (which repeats every page anyway) works as a solution.

For the detail section, I did use a table simply because it made the row and column layouts easier but again, since I had 4 rows and 18 columns with lots of merged cells, the designer started to get really confused again and would create un-renderable reports. Now, it certainly could have been user entry problems on my end too. The only way I was able to get the report working was to completely remove all the stock cells in the default table so all groupings were gone, then I was able to simply add my rows and columns back and there were no 'within group' and 'outside group' options and hence the table was as simple as it could get. I was able to set my Cell textboxes to the correct fields ( = Fields.CarName ) and all seems to be working now.

So I digress... I must say, that I have worked with Crystal, Telerik and Microsoft RDL. I love Telerik products and no judgement on quality, I just don't like working in frameworks of reporting where stuff is done at design, time. I live in code-land so I generally get very dynamic report needs. I wish that Telerik would just allow us to understand their equivalent of RDL (the final XML) and render it directly to the report viewer the way that MS does with RDL. I wonder how close Telerik RDL is to MS RDL?? :-) 

I couldn't live without my RadControls (ASP + Winforms) tho... best in class!!!!

cheers!!

jess
Tags
General Discussions
Asked by
Jess Askey
Top achievements
Rank 2
Answers by
Massimiliano Bassili
Top achievements
Rank 1
Jess Askey
Top achievements
Rank 2
Share this question
or