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

Set datasource of table same as report data source

14 Answers 2469 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Roberto Yudice
Top achievements
Rank 1
Roberto Yudice asked on 27 May 2010, 06:59 PM
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!

14 Answers, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 28 May 2010, 04:26 PM
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.
0
Roberto Yudice
Top achievements
Rank 1
answered on 28 May 2010, 04:42 PM
Thank you, it's exactly what I wanted.
0
rocky
Top achievements
Rank 1
answered on 17 Oct 2011, 06:38 AM
when i bind table to the same datasource of main report, table are created for each datarow...
0
Peter
Telerik team
answered on 19 Oct 2011, 04:59 PM
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.

0
Vicky
Top achievements
Rank 1
answered on 19 Jun 2013, 03:26 PM
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
0
Peter
Telerik team
answered on 24 Jun 2013, 08:40 AM
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.

0
Jolanta
Top achievements
Rank 1
Veteran
answered on 23 Jan 2016, 06:26 PM

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

0
Stef
Telerik team
answered on 26 Jan 2016, 02:19 PM
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
0
Jolanta
Top achievements
Rank 1
Veteran
answered on 27 Jan 2016, 08:09 AM

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

0
Stef
Telerik team
answered on 28 Jan 2016, 08:23 AM
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
0
Jolanta
Top achievements
Rank 1
Veteran
answered on 29 Jan 2016, 10:36 AM

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

0
Stef
Telerik team
answered on 29 Jan 2016, 04:50 PM
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
0
Juan Sebastián
Top achievements
Rank 1
answered on 24 Oct 2018, 08:58 PM
Hey, I am trying to get the data from a data source with a filter, but the program is printing a lot of tables I don't know if there is a way to limit the data from data source to print just the one that have for example an id = 1 and no more, pls help.
0
Silviya
Telerik team
answered on 29 Oct 2018, 07:36 AM
Hello Juan,

When a Report is databound, it is intended that the detail section will be duplicated for each row returned by the dataset. A Table can also be databound, and the expected result is that the detail row of the table will be duplicated for each row in the dataset. When both are databound, and the table is inside the detail section - you will see multiple copies of the table (with the headers).

In order to get rid of the repeating Tables, there are two possible approaches: 
  1. Leave the DataSource of the report to None and set only the DataSource of the Table item.
  2. Move the Table to a report section that doesn't duplicate - such as group headers or footers of a static group.

Regards,
Silviya
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
Tags
General Discussions
Asked by
Roberto Yudice
Top achievements
Rank 1
Answers by
Steve
Telerik team
Roberto Yudice
Top achievements
Rank 1
rocky
Top achievements
Rank 1
Peter
Telerik team
Vicky
Top achievements
Rank 1
Jolanta
Top achievements
Rank 1
Veteran
Stef
Telerik team
Juan Sebastián
Top achievements
Rank 1
Silviya
Telerik team
Share this question
or