How to? CsvDataSource

1 Answer 38 Views
DataSource CSV Report Designer (standalone)
Geir Otto
Top achievements
Rank 1
Geir Otto asked on 26 Jan 2022, 10:58 PM

I am a newbi to Telerik.Reporting, and wants to understand how CsvDataSource is connected to the Report. 

If I want to add two DataSources:

Source1:

MyCompanyId Name address ..... accountnumbers ..... <-- meta data for the heading of an invoice

Source2:

CustNum Name Address ...... etc    <-- these are meta data for the customer

Source3:

CustNum OrderNum ItemNum <-- these are the details of the report

How should I do this? I understand that if I put everyting on each line of Source3, it will work, but then I add a lot of unnesseary data.. 

I could probably add a Type: H for header and R for row on Source3 so that I only need to add an empty space for each of the header data, but that also seems kind of .... 

What will be the best way of doing this?

What if I use Json? Would that be easier? and if so, how?

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 31 Jan 2022, 11:59 AM

Hello Geir Otto,

If I understood correctly, you would like to use CsvDataSource(s) that contain header data that would be displayed once per report/group, and detail data. You don't want to duplicate the header data with each detail row.

I suggest using two or three different data sources. The ones that are going to be displayed only once may be linked to a List or Table that would display this information, for example, in a Report Header. The detailed data may be bound to the Report, so that it may render one detail section for each data row. The approach is demonstrated in the attached report "ReportCsv.trdp".

With JsonDataSource you may indeed structure all in a single data source without duplication. The Company meta-info and the Customer meta-info would be in two complex fields, and the detailed data will be the third field that would be a collection. You may render the third field in a nested List or other data item. The DataSource may be set with Binding, as demonstrated in the attached report "ReportJson.trdp". For more details, you may check also the article How to use the ReportItem.DataObject property in expressions.

Note that depending on the exact scenario, you may design the report to group the data, for example, by item type, etc.

Regards,
Todor
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
Geir Otto
Top achievements
Rank 1
commented on 03 Feb 2022, 09:08 AM

Thanks, looking into the Csv, and make sence. In the Csv example, there is no connection between the datasources? So when the report is opening, it will  spin on the datasource3, since that source is added in the deailsection. Is it so that if I want to spin on a datasource, it needs to be in the deailsection? so if I have datasourceCustomer and datasourceOrder, I will put both datasources in detailsection and bind them so that datasourceOrder will be filtered on datasourceCustomer? so each time the datasourceCustomer is chaning, it will fill the datasourceCustomer with correct info.. 
Todor
Telerik team
commented on 08 Feb 2022, 08:13 AM

Indeed, the detail sections of the data items are rendered/instantiated for each data record from the corresponding data source. For example, in the sample, the Report details section is rendered for each record of csvDataSource3. Importantly, each data item may have only one data source. That said, the detail sections are generated based on a single data source. The data items may share a data source.

With the customer-orders scenario, you may use the datasourceCustomer as a data source for the Report. If there are many customers, you may group the Report by the customer. Each Report Group will display only the data for the corresponding customer. You may use this value to filter datasourceOrder that is assigned to a list/table within the group. The list/table will display the orders data.

In case the report is for a single customer, you may assign the datasourceCustomer to the Report and use a list/table with datasourceOrder filtered by the customer to display its orders. There is no need for groups as there is only one data record. the details section of the report will be rendered once, and the table inside will display all the orders.

Tags
DataSource CSV Report Designer (standalone)
Asked by
Geir Otto
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or