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

Report datasource avalaible at run time

2 Answers 270 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tamas
Top achievements
Rank 1
Tamas asked on 22 May 2013, 10:59 AM
Hi!

I create a trdx report in Telerik Report Designer. After I added this report to my project.

Telerik.Reporting.UriReportSource uriReportSource = new Telerik.Reporting.UriReportSource();
            uriReportSource.Uri = @"Report\teszt.trdx";
            TelRptViewer.ReportSource = uriReportSource;


I want to add a dataTable to report programatically. So my data is not avalible at design time.
I check some topic in help.
Working With Data at Design Time

"In this case you would have to mock your data just to enable the Report Designer to show any data schema. "
I don't understand this. How it is possible?

I already check this links too.
Using the NeedDataSource event to connect data
How to: Bind to a DataTable

My main problem is the next I don't really know or understand how to set a data-schema in designer.
Thx

2 Answers, 1 is accepted

Sort by
0
Tamas
Top achievements
Rank 1
answered on 23 May 2013, 08:26 AM
I use the next code to bind a datatable to report.

Reports.Report1 report = new Reports.Report1();
 
Telerik.Reporting.ObjectDataSource objectDataSource = new Telerik.Reporting.ObjectDataSource();
objectDataSource.DataSource = CreateData().Tables[0];
report.DataSource = objectDataSource;          
             
Telerik.Reporting.InstanceReportSource reportSource = new Telerik.Reporting.InstanceReportSource();
reportSource.ReportDocument = report;
TelRptViewer.ReportSource = reportSource;

My report contains a simple table dataitem with 3 columns.
I have already read this topic in help.
Working With Data at Design Time - Data source available only at runtime

"This approach is useful when you cannot get the report's data source at design time or want to avoid loading real data into Visual Studio at design time. In this case you would have to mock your data just to enable the Report Designer to show any data schema. This will enable you to adjust the layout of the report and bind report items to the available data fields, while the real data will be loaded only at runtime either in NeedDataSource event or in the actual application. "

In simple reportviewer there was an xsd which prove the data schema for report.
In this viewer how its is possible to make this data schema or similar? Or there is another way to do this?

Thx.
0
Accepted
Peter
Telerik team
answered on 24 May 2013, 09:40 AM
Hi Tamas,

We retrieve the data schema automatically based on the datasource type. Thus if in the report designer (data explorer and expression editor) fields list is empty we will appreciate if you elaborate on your data layer (CreateData() method). 

Generally you can try to debug Visual Studio design time - while you are using the Visual Studio report designer you have to open another Visual Studio instance, select Debug->Attach to process to debug another instance of devenv.exe and select Debug->Exception... to enable  the First Chance Exceptions.

Regards,
Peter
Telerik

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

Tags
General Discussions
Asked by
Tamas
Top achievements
Rank 1
Answers by
Tamas
Top achievements
Rank 1
Peter
Telerik team
Share this question
or