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

Crosstab Report tutorial with objects

6 Answers 288 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 26 Sep 2013, 08:56 PM
I have been looking for an example of displaying data in objects that have data items in a list. I can display the first level "items" in a table but cannot retrieve the attributeItems data to display.

I want the report to look like this:
Name        Attribute Name     Attribute Value
XXXX        XXXXXXX                XXXXXX
                XXXXXXX                XXXXXX
XXXX        XXXXX                    XXXX
                XXXX                        XXXXXXX
                XXXXX                        XXXXX
I have yet to find any examples using objects or even a decent tutorial on crosstab reports. I have downloaded one project but this is returning a datatable object.

Here is the report code.

namespace

 

 

Reports

 

{

 

 

using System;

 

 

 

using System.Collections.Generic;

 

 

 

using System.ComponentModel;

 

 

 

using System.Drawing;

 

 

 

using System.Windows.Forms;

 

 

 

using Telerik.Reporting;

 

 

 

using Telerik.Reporting.Drawing;

 

 

 

/// <summary>

 

 

 

/// Summary description for CrossTabReport.

 

 

 

/// </summary>

 

 

 

public partial class CrossTabReport : Telerik.Reporting.Report

 

{

 

 

public CrossTabReport()

 

{

 

InitializeComponent();

}

}

[

 

DataObject]

 

 

 

public class CrossTabReportModel {

 

[

 

DataObjectMethod(DataObjectMethodType.Select)]

 

 

 

public CrossTabData getData() {

 

 

 

return new CrossTabData();

 

}

}

 

 

public class CrossTabData {

 

 

 

public CrossTabData() {

 

title =

 

"CROSS TAB DATA";

 

items =

 

new List<CrossTabItem>() {

 

 

 

new CrossTabItem { itemName = "FRED",

 

itemAttributes =

 

new List<ItemAttribute>()

 

{

 

 

new ItemAttribute{ attribName = "HAIR", attribValue= "BROWN"},

 

 

 

new ItemAttribute{ attribName = "EYES", attribValue= "BROWN"},

 

 

 

new ItemAttribute{ attribName = "HEIGHT", attribValue= "5'6"},

 

 

 

new ItemAttribute{ attribName = "WEIGHT", attribValue= "200"}

 

}

},

 

 

new CrossTabItem { itemName = "SAM",

 

itemAttributes =

 

new List<ItemAttribute>()

 

{

 

 

new ItemAttribute{ attribName = "HAIR", attribValue= "BLONDE"},

 

 

 

new ItemAttribute{ attribName = "EYES", attribValue= "BLUE"},

 

 

 

new ItemAttribute{ attribName = "HEIGHT", attribValue= "6'0"},

 

 

 

new ItemAttribute{ attribName = "WEIGHT", attribValue= "210"}

 

}

},

 

 

new CrossTabItem { itemName = "CHILLY",

 

itemAttributes =

 

new List<ItemAttribute>()

 

{

 

 

new ItemAttribute{ attribName = "HAIR", attribValue= "BROWN"},

 

 

 

new ItemAttribute{ attribName = "EYES", attribValue= "GREEN"},

 

 

 

new ItemAttribute{ attribName = "HEIGHT", attribValue= "5'10"},

 

 

 

new ItemAttribute{ attribName = "WEIGHT", attribValue= "150"}

 

}

}

};

}

 

 

public string title { get; set; }

 

 

 

public List<CrossTabItem> items { get; set; }

 

}

 

 

public class CrossTabItem {

 

 

 

public string itemName { get; set; }

 

 

 

public List<ItemAttribute> itemAttributes { get; set; }

 

}

 

 

public class ItemAttribute {

 

 

 

public string attribName { get; set; }

 

 

 

public string attribValue { get; set; }

 

}

}

Thanks for any help.

6 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 02 Oct 2013, 09:14 AM
Hi Michelle,

You can use nested Table items and bindings to assign their DataSource properties. The attached sample project illustrates the suggested.

More details and example can be found in the following forum post: Data Source Business Objects.

Regards,
Stef
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

0
Randy
Top achievements
Rank 1
answered on 02 Oct 2013, 03:25 PM
I already looked at that thread - it only shows 1 level and I need to know how to display more complex  data than that. I tried nested tables and the preview kinda "wigged out" so hopefully your example will help me figure out what I did wrong.  Also, I found no good tutorials on groups - could you point me to some decent examples of how to setup groups?

Thanks!
0
Randy
Top achievements
Rank 1
answered on 02 Oct 2013, 06:54 PM
Ok I ran your report and works great. I try to duplicate it and the preview flashes the report and puts me back in the designer everytime I try to preview. I cannot find the difference between your report and my duplicate. When the report flashes it looks like it is loading corrrectly but it is so quick that I cannot see the entire thing. This is occurring when I add the table into the second row/column to display the attribute details. If I preview prior to that everything works normally. Any help would be appreciated - Thanks!
0
Randy
Top achievements
Rank 1
answered on 02 Oct 2013, 08:50 PM
Ok I have my version working. I had to build the second table outside of the first table. Then when finished I added it to the first table.
0
Yoni
Top achievements
Rank 1
answered on 20 Jan 2014, 01:30 PM

Hello, Michelle.


I think I have a simular issue that you have resolved.

I will be more than appriciate if you can share your solution with me.



Thanks in advance,

Yaron

0
Stef
Telerik team
answered on 22 Jan 2014, 06:46 PM
Hello Yaron,

Please take a look at the following help articles, which may help you:

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

Tags
General Discussions
Asked by
Randy
Top achievements
Rank 1
Answers by
Stef
Telerik team
Randy
Top achievements
Rank 1
Yoni
Top achievements
Rank 1
Share this question
or