Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
475
Hierarchical data in reports
posted

Hi,

I am attempting to reference hierarchical data from within a 2011.2 report. This is something that I think was missing from the CTP versions and I was expecting it to be possible in the released version.

From reading the documentation it appears that you can create data that is relational in the report but it appears to work from the detail level up to a single parent rather than from a parent down to multiple detail levels.

An example would be where you have a top level (a project) which relates to multiple customers that each have zero or more addresses and communication methods. Like this;

Project

/                                               \

Customers                            Stages

/                               \

Addresses             Communication Methods

In the sample code, the hierarchy always seems to start at a detail level and then work backwards up the data-tree.

Here is some sample code to create the hierarchical data described;

    [ReportDataSourceExport(ReportSearchPattern = "PrintProject.*")]

    public class PrintProjectDataProvider : IReportDataSourceProvider

    {

        public object GetDataSource(string name, IDictionary<string, ParameterValue> reportParameters)

        {

            switch (name)

            {

                case "Project":

                    LoadProjectDetails();

                    return Projects;

                default:

                    return null;

            }

        }

 

        private void LoadProjectDetails()

        {

            Projects.Clear();

            var toAdd = new ProjectDetailsViewModel

                            {

                                ProjRef = "ProjRef",

                                Description = "Project Description",

                                Date = DateTime.Now.Date

                            };

            toAdd.Stages.Add(new ProjectStageDetailsModel {StageNo = "1"});

            toAdd.Stages.Add(new ProjectStageDetailsModel {StageNo = "2"});

            toAdd.Stages.Add(new ProjectStageDetailsModel {StageNo = "3"});

            var customer1 = new CustomerDetailsViewModel { Name = "Mr Jim Elf Exit" };

            var customer2 = new CustomerDetailsViewModel { Name = "Mrs Main Tester" };

            var customer3 = new CustomerDetailsViewModel { Name = "Miss Final Customer" };

            toAdd.Customers.AddRange(new []{customer1,customer2,customer3});

            customer1.Addresses.Add(new AddressViewModel { Line1 = "Road Name", PostCode = "PO573DE" });

            customer1.Addresses.Add(new AddressViewModel { Line1 = "Test Street", PostCode = "TE571NG" });

            customer1.CommunicationMethods.Add(new CommunicationMethod { Description = "Email", Detials = "first.last@domain.ext" });

            customer1.CommunicationMethods.Add(new CommunicationMethod { Description = "Mobile", Detials = "07890 123456" });

            customer1.CommunicationMethods.Add(new CommunicationMethod { Description = "Work", Detials = "01234 567890"});

            Projects.Add(toAdd);

        }

 

        private List<ProjectDetailsViewModel> _projects = new List<ProjectDetailsViewModel>();

        public List<ProjectDetailsViewModel> Projects

        {

            get { return _projects ; }

            set { _projects  = value; }

        }

    }

 

    public class ProjectDetailsViewModel

    {

        public String ProjRef { get; set; }

        public String Description { get; set; }

        public DateTime Date { get; set; }

        private List<ProjectStageDetailsModel> _stages = new List<ProjectStageDetailsModel>();

        public List<ProjectStageDetailsModel> Stages

        {

            get { return _stages; }

            set { _stages = value; }

        }

        private List<CustomerDetailsViewModel> _customers = new List<CustomerDetailsViewModel>();

        public List<CustomerDetailsViewModel> Customers

        {

            get { return _customers; }

            set { _customers = value; }

        }

    }

 

    public class CustomerDetailsViewModel

    {

        public String Name { get; set; }

        private readonly List<AddressViewModel> _addresses = new List<AddressViewModel>();

        public List<AddressViewModel> Addresses

        {

            get { return _addresses; }

        }

        private readonly List<CommunicationMethod> _communicationMethods = new List<CommunicationMethod>();

        public List<CommunicationMethod> CommunicationMethods

        {

            get { return _communicationMethods; }

        }

    }

 

    public class AddressViewModel

    {

        public String Line1 { get; set; }

        public String PostCode { get; set; }

    }

 

    public class CommunicationMethod

    {

        public String Description { get; set; }

        public String Detials { get; set; }

    }

 

    public class ProjectStageDetailsModel

    {

        public String StageNo { get; set; }

    }

Using this data, I would hope to be able to produce a report that looks like this;

 

Thanks in advance for your help.

Best regards,

Timothy. 

Parents
No Data
Reply
  • 3070
    posted

    Hi Timothy,

    We don’t support hierarchical data sources in 2011.2; it is very possible that they will be included for next version. Currently the only way to display hierarchies inside a report is by grouping data. i.e. data must be flat and you build the hierarchy by grouping. If you have only one child you would be able to build the hierarchy, but since you have two children for the project that will not be possible.

    Thanks,

    Leo

Children