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

Reports to Report-viewer Programtically

6 Answers 283 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Waseem
Top achievements
Rank 1
Waseem asked on 02 Jul 2017, 08:27 AM

Hi, 

Working on Demo Project and need to understand the work flow for telerik reports. 

1. I create Report Library were i have "RouteCustomerReport.vb"  ("Design Only" not connected with any datasource)

2. I have another project where i import ZulalReportLibrary.dll

3. Below Code display the report without data. 

 

 Private Sub frmRouteCustomerReport_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim rpt As New ZulalReportLibrary.RouteCustomerReport
        rpt.DataSource = MyDataSource()

        Dim TRS As New Telerik.Reporting.TypeReportSource
        TRS.TypeName = "ZulalReportLibrary.RouteCustomerReport, ZulalReportLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

        ReportViewer1.ReportSource = TRS
        ReportViewer1.RefreshReport()

    End Sub

 

6 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 03 Jul 2017, 02:41 PM
Hi Waseem,

Let us start from report sources - Report Sources.

Report Sources are used to specify the format of the report:
  • UriReportSource for TRDP and TRDX files without modifications. The reporting engine deserializes the content t of he file at run-time to get a Telerik.Reporting.Report object for processing and rendering;
  • TypeReportSource for report classes inheriting Telerik.Reporting.Report (reports created by VS Report Designer) without modifications. The reporting engine uses reflection to create an instance of the report class at run-time by using the report's default parameterless constructor;
  • InstanceReportSource for reports created by the VS Report Designer or report instances created/modified at run-time.

If you want to modify reports before displaying them, you will need to use an InstanceReportSource.

In addition, load the report in a Report Designer and check its structure via Report Explorer. If data is visualized by a nested data item (Table/List/Crosstab/Map/Graph), you need to find the item and to set that item's DataSource at run-time e.g.:
Dim rpt As New ZulalReportLibrary.RouteCustomerReport
Dim tableItem = DirectCast(rpt.Items.Find("Table1",True)(0), Telerik.Reporting.Table)
tableItem.DataSource = MyDataSource()
 
Dim IRS As New Telerik.Reporting.InstanceReportSource
IRS.ReportDocument= rpt
 
ReportViewer1.ReportSource = IRS
.....



Regards,
Stef
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
0
Waseem
Top achievements
Rank 1
answered on 08 Jul 2017, 02:46 PM

Hi ,

that's perfect example to understand the InstanceReportSource. thanks for that.

pin this example and in design view example having SQL datasource in both I am facing preview issue. its not as we want to see.

PFA

 

0
Accepted
Stef
Telerik team
answered on 10 Jul 2017, 12:51 PM
Hello Waseem,

Based on the screenshots, please test changing the Encoding of the Barcode item in such manner that the longest string from the data source can be presented via barcode e.g. QR barcode - Barcode Types and Specifics.

To avoid the resizing of the Barcode item, you can add a Panel item in the cell and then the Barcode item without Docking and Anchoring. This will make the Panel item resize, but it will keep the design-time size of the Barcode item.

Regards,
Stef
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
0
Waseem
Top achievements
Rank 1
answered on 24 Oct 2017, 05:34 AM

Hi Stef,

I have done this in more programmatically, I have form where user can select the route and route_day, by selecting route_day, report display only first day of route. (it means it will reset the index to 1 or 0 first item in the list)

can you please help me why is this happening.

 

Thanks

 

0
Waseem
Top achievements
Rank 1
answered on 24 Oct 2017, 05:35 AM

Click event code is here

---------------------------------------------------------------------------------------

   Dim rpt As New ZulalReportLibrary.RouteCustomerReport
            'rpt.DataSource = MyDataSource()

            Dim tableItem = DirectCast(rpt.Items.Find("Table2", True)(0), Telerik.Reporting.Table)
            tableItem.DataSource = MyDataSource()
            Dim IRS As New Telerik.Reporting.InstanceReportSource
            IRS.ReportDocument = rpt


            Dim report As Telerik.Reporting.Report = DirectCast(IRS.ReportDocument, Telerik.Reporting.Report)
            Dim txtTerritory As Telerik.Reporting.TextBox = TryCast(report.Items.Find("txtTerritory", True)(0), Telerik.Reporting.TextBox)
            Dim txtRoute As Telerik.Reporting.TextBox = TryCast(report.Items.Find("txtRoute", True)(0), Telerik.Reporting.TextBox)
            txtTerritory.Value = " Territory " & drpTerritory.SelectedValue.ToString
            txtRoute.Value = " Visiting Route of  " & drpRoute.Text
            MsgBox("Drp Value" & drpTerritory.SelectedValue.ToString & "-" & "Text Value " & drpRoute.Text)

            ReportViewer1.ReportSource = IRS
            ReportViewer1.RefreshReport()

 

-----------------------------------------------------------------------------

0
Waseem
Top achievements
Rank 1
answered on 24 Oct 2017, 06:40 AM

Dear Stef,

I got the solution, MyDatasource function resetting the values.

 

Thanks

 

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