Set datasource of table same as report data source

13 posts, 1 answers
  1. Roberto Yudice
    Roberto Yudice avatar
    16 posts
    Member since:
    Mar 2010

    Posted 27 May 2010 Link to this post

    I'm trying to evaluate some fields inside a table in my report, however I see that the table has its own datasource property, I want to set the datasource property to be the same as the report's datasource, how can I do so? thanks!
  2. Answer
    Steve
    Admin
    Steve avatar
    10941 posts

    Posted 28 May 2010 Link to this post

    Hello Roberto,

    Setting the same datasource to a report and a table is usually not desired as this way, the same database rows would be repeated for the detail section in the report as well as in the table. Generally how you proceed is based on what you want to achieve. There are two options:
    1. Set the same datasource as in the report and apply a filter to the Table. You can filter the table datasource based on the main report's datasource by using =ReportItem.Parent.DataObject. From here on, you can be more concrete and define the exact field you would filter upon like so:

      =ReportItem.Parent.DataObject.IDFieldFromMainReport

      or based on your own conditions (e.g. report parameters).
    2. Use the Bindings property of the Table item to bind it to the same source as the report by using the following expression: =ReportItem.DataObject. You can see this in action in our ProductCatalog demo report.

    Hope this helps.

    Regards,
    Steve
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Roberto Yudice
    Roberto Yudice avatar
    16 posts
    Member since:
    Mar 2010

    Posted 28 May 2010 Link to this post

    Thank you, it's exactly what I wanted.
  5. rocky
    rocky avatar
    11 posts
    Member since:
    Aug 2010

    Posted 17 Oct 2011 Link to this post

    when i bind table to the same datasource of main report, table are created for each datarow...
  6. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 19 Oct 2011 Link to this post

    Hello Rocky,

    Generally a detail section is printed once for every data record. Thus if you want to have only one table instance our suggestion is to move the table item to a non repeater section such as an unbound group (group without grouping) footer/header section.

    Kind regards,
    Peter
    the Telerik team

    Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

  7. Vicky
    Vicky avatar
    1 posts
    Member since:
    May 2013

    Posted 19 Jun 2013 Link to this post

    Great the solutions was good

    I have one last problem in this kind of report

    I have placed two table tools in the group header. One  table shows all the rows which is correct it should as the values are different but in second table should only show one row as the values of all the fields are identical. How can I suppress the repeated values in the group header for the same Client id
  8. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 24 Jun 2013 Link to this post

    Hello Vicky,

    Our suggestion is to set up a table/crosstab group to eliminate the duplicates. In order to set up a crosstab you can can use the crosstab wizard.

    Additionally you may find useful the Grouping Data help articles.

    Regards,
    Peter
    Telerik

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

  9. Jolanta
    Jolanta avatar
    19 posts
    Member since:
    Oct 2014

    Posted 23 Jan in reply to Peter Link to this post

    Hi,

    I have a question: I have 3 tables used one DataSource.

    If I create each table, adding same DataSource (as DataSource property) - do the DataSource is generates 3 times independently, as if there were 3 separate DataSource objects?

    Is there an adventage, if I set this DataSource as report DataSource and then bind each table to it, with: ReportItem.DataObject?
    (I have to do it not in detail section, but e.g. in header and it works ok) - is then this DataSource generated only once and the data are transported only once from server?

    Jola

  10. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 26 Jan Link to this post

    Hi Jola,

    If a data item's DataSource is set directly, the item will request data each time it is rendered in the report (because the item can be placed in a repeating section).

    If a data item's DataSource s set via binding to the container's data object, the data will be requested by  the container' Datasource and then it will be reused by the nested data item (no second data-retrieving occurs). Details about this data-binding approach are available in How to use the ReportItem.DataObject property in expressions.

    Regards,
    Stef
    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
  11. Jolanta
    Jolanta avatar
    19 posts
    Member since:
    Oct 2014

    Posted 27 Jan in reply to Stef Link to this post

    Thank you for the answer.

    So - if I want to use a DataSource in multiple tables, it make sense to put this DataSource as report-object and refer to it via binding.

    Jola

  12. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 28 Jan Link to this post

    Hello Jola,

    Yes, I can confirm that it is a suitable approach if you have many data items using the same data source.

    Regards,
    Stef
    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
  13. Jolanta
    Jolanta avatar
    19 posts
    Member since:
    Oct 2014

    Posted 29 Jan in reply to Stef Link to this post

    Hi, thanks for answer, unfortunately I have found, that calculated fields are not recognized, via Fields.myField, if DataSource is set to report and used in table via binding:( (in simple usage table<->DataSource, calculated fields are  recognized in same way as original fields).

    Jola

  14. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 29 Jan Link to this post

    Hi Jola,

    Please check the attached demo report (TRDX file). It can be previewed with the Standalone Report Designer of Telerik Reporting Q1 2016 and requires a connection string to AdventureWorks database.

    There is a SqlDataSource with two calculated fields.
    The report's DataSource is set to the SqlDataSource component (sqlDataSource1). You can see the data in the Detail section. There is also a Table item in static group's header section - the Table.DataSource is set via binding to the report data object.

    The Table item displays the calculated fields added to the SqlDataSource component that is used by the report.


    Please elaborate on your settings and include details how to reproduce the problem.

    Regards,
    Stef
    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
DevCraft banner