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

Crosstab using ObjectDataSource with nested collections

1 Answer 272 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Roland
Top achievements
Rank 1
Roland asked on 18 Oct 2012, 02:24 PM
Hello,

I am working on a report that resembles mostly a crosstab, thatswhy I consider using it. 
My problem is to solve the binding of the objectdatasource, that is a List inside a List.

Looks like the following:

public class GroupedLine
    {
        public string Group { get; set; }
        public BookingType Type { get; set; }
        public BookingStatus Status { get; set; }
        public List<WeeklyStat> WeeklyStats { get; set; }
    }


    public class WeeklyStat
    {
        public DateTime WeekStart { get; set; }
        public decimal Sum { get; set; }
        public int Count { get; set; }
    }

I create a DataSource binding to the CrossTab to this list: List<GroupedLine> GroupedLines.

But I am having trouble figuring out the binding of WeeklyStats that can have as many elements as the number of weeks the user selects in the report parameters. 

I'd like to ask for advice how to accomplish a result like this (in case the selection covers a 5 weeks range):

                                 	Week 22     Week 23     Week 24     Week 25     Week 26
                                       
May28-Jun3  Jun4-10     Jun11-17    Jun18-24    Jun25-Jul1
           
Group   Type    Status      Cnt. Price  Cnt. Price  Cnt. Price  Cnt. Price  Cnt. Price
           
----------------------------------------------------------------------------------------------
           
Group1  Online  New         3   450     0   0       0   0       0   0       0   0
           
Group2  Phone   Accepted    0   0       1   80      1   110     0   0       0   0
           
Group3  Store   Accepted    0   0       0   0       0   0       1   225     0   0      
           
Group3  Store   Invoiced    0   0       0   0       0   0       2   440     0   0          

1 Answer, 1 is accepted

Sort by
0
IvanY
Telerik team
answered on 23 Oct 2012, 08:46 AM
Hello Roland,

I have attached an example that shows how to create your master detail relation. The main idea is that you assign your data source to the report itself. After that you place the textboxes needed and a crosstab in a panel and bind to the respective fields. After that use Binding to bind the data source of the crosstab to be "= Fields.WeeklyStats". Once you have done that you can create groupings and add detail fields as per your requirements. To have design time support for your crosstab you can create a second ObjectDataSource that retrieves a single WeeklyStat (the method can just return array of one item, which is created without setting the properties - check the attached sample for more info).

Kind regards,
IvanY
the Telerik team

HAPPY WITH TELERIK 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
Roland
Top achievements
Rank 1
Answers by
IvanY
Telerik team
Share this question
or