Class as ObjectDataSource

6 posts, 1 answers
  1. Masoud
    Masoud avatar
    61 posts
    Member since:
    Aug 2011

    Posted 05 Apr 2012 Link to this post

    Hi there,

    I am looking at generating reports based on a class that has the following structure:

    public class DataItem
    {
        public string ItemHeader { get; set; }
        public string ItemContent { get; set; }
        public string ItemFooter { get; set; }
    }
     
    public class ReportingDataSource00
    {
        public ReportingDataSource00()
        {
            DataItems = new List<DataItem>
                            {
                                new DataItem {ItemContent = "ItemContent00", ItemFooter = "Footer00", ItemHeader = "Header00"},
                                new DataItem {ItemContent = "ItemContent01", ItemFooter = "Footer01", ItemHeader = "Header01"}
                            };
            ReportHeader = "Header";
            ReportFooter = "Footer";
        }
     
        public string ReportHeader { get; set; }
        public string ReportFooter { get; set; }
        public IEnumerable<DataItem> DataItems { get; set; }
    }

    ReportingDataSource00 has data that needs to be displayed only once on the report (header and footer), as well as a list of elements that need to be displayed in a table.  

    When I try to use ReportingDataSource00 as a ObjectDataSource, the wizard will only recognize the properties Header and Footer.  Is it possible to use the DataItems list as a datasource for a list in the detail section of the report?

    Best regardes




  2. Answer
    Elian
    Admin
    Elian avatar
    435 posts

    Posted 09 Apr 2012 Link to this post

    Hi Klaus,

    The concept of the DataSource is to be a List of some data items that will be iterated through in order to create the report (one detail section for each iteration). In your case the List is not the top of the hierarchy and this is why you can't use the DataItems List for displaying items in the detail section. You can however use it as DataSource for Table/List/Crosstab items with Bindings. However if you need to use it as Report.DataSource you will need to rework it, so it only retrieves the data for the report (without the header and the footer). 

    Regards,
    Elian
    the Telerik team
    NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.
  3. InSource
    InSource avatar
    2 posts
    Member since:
    Dec 2010

    Posted 08 May 2012 Link to this post

    I have an MVC application that uses business object classes and a DAL.
    I wish to use telerik reporting in my application using these classes but am having difficulty finding examples of how to use the objectDataSource.  Can you provide a snippet or an example?
  4. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 08 May 2012 Link to this post

    Hello,

    Check the following links:

    Kind regards,
    Steve
    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 >

  5. John
    John avatar
    1 posts
    Member since:
    Jan 2017

    Posted 19 Nov in reply to Elian Link to this post

    Then how would you get the header and footer info? should we repeat the header and footer information in the collection so we can use it?
  6. Katia
    Admin
    Katia avatar
    616 posts

    Posted 22 Nov Link to this post

    Hi John,

    Header and footer information can be retrieved inside the report's (or inner data item) detail section. In this case, header and footer will be repeated for each detail section. Otherwise, you can show only the ItemContent in the detail section and display header and footer in another report section where the content can be aggregated, for example Group Header(Footer) or Report Header(Footer).
    Inside those sections, you can use aggregate built-in functions to calculate the result based on the set of values returned by the data source.

    Regards,
    Katia
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top