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

Tables within the details section

2 Answers 240 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tormod
Top achievements
Rank 1
Tormod asked on 19 Sep 2012, 12:44 PM
Hi.

Within my details section, I wish some of the reportitem properties to be written out as a table.
The data source is ObjectDataSource (clr object).

If I have a datasource like this

class DetailObject
{
public int Prop1 {get;set;}
public int Prop2 {get;set;} 
public int Prop3 {get;set;} 
public int Prop4 {get;set;} 
public int Prop5 {get;set;} 
public int Prop6 {get;set;}  
}

I want properties 1,2 and 4 to be written out as a table within the details section and 3 and 5 in another table.
I am faced with the problem that tables need to be bound to collections. Leaving the datasource empty or binding to "= ReportItem" causes the table not to render at all (instead of rendering one and allow direct access to reportitem properties).

The workaround appears to be to create a value object that matches the the table layout and fake a list. Like this:

class Table1Values
{
public int DetailProp1 {get;set;}
public int DetailProp2 {get;set;} 
public int DetailProp4 {get;set;}  
}

class Table2Values
{
public int DetailProp3 {get;set;}
public int DetailProp5 {get;set;} 
} 

And then expand my DetailObject class with an Enumerable like this:

class DetailObject
{ 
// ( all the other stuff) 

public IEnumerable Table1Data {
get {
yield return new Table1Values
{ DetailProp1 = Prop1, 
DetailProp2 = Prop2,
DetailProp4 = Prop4
};
}};
}

Then it is possible to bind a table datasource to "=Fields.Table1Data" and binding cells to DetailProp1, DetailProp2 and DetailProp4. 

Am I missing something obvious, or is this how one should go about creating a table within the details section where the table is a table layout of predetermined individual ReportItem properties?

2 Answers, 1 is accepted

Sort by
0
Accepted
Elian
Telerik team
answered on 24 Sep 2012, 02:26 PM
Hello Tormod,

Reworking your data is not necessary in this case. The "=ReportItem" expressions gives you the current item (in your case it would be the detail section). To get it's data object you need the following expression:
"= ReportItem.DataObject" and if you use this expression for DataSource of the table, you will be able to use the fields as in normal textboxes in the detail section. 
 
Kind regards,
Elian
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Tormod
Top achievements
Rank 1
answered on 25 Sep 2012, 06:28 AM
Awesome! You won't believe what I was about to do to my object model and hence how poorly it would lend itself to the LINQPad dump() method. 
Suffice to say that iterators featuring just the phrase "yield return this" started to pop up around the scene. I thought that the binding to datasource had to be a collection.
Tags
General Discussions
Asked by
Tormod
Top achievements
Rank 1
Answers by
Elian
Telerik team
Tormod
Top achievements
Rank 1
Share this question
or