Telerik Forums
Reporting Forum
1 answer
228 views

Hi Team,

 

Good Day!

 

I am using a Standalone Telerik Report and I want to set a new ObjectDataSource from a Dataset during run-time. But even how much I tried the report cannot retrieved or used the new ObjectDataSource that I set during run-time. Below is My Code. Please kindly help assist on which part of my code do i get wrong or is this possible in Telerik Report?

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

        Try


            Me.Text = CurrReport.FileName
            Dim uriReportSource As New Telerik.Reporting.UriReportSource()

            uriReportSource.Uri = IO.Path.GetDirectoryName(Diagnostics.Process.GetCurrentProcess().MainModule.FileName) & "\Reports\" & CurrReport.ReportName

            ReportViewer1.Cursor = Windows.Forms.Cursors.Default
            ReportViewer1.ReportSource = SetUpReportSource(uriReportSource)
            ReportViewer1.RefreshReport()

        Catch ex As Exception
            Glenfield.Common.HandleError(ex)

        End Try

    End Sub

    Public Function SetUpReportSource(sourceReportSource As ReportSource) As ReportSource
        Try
            Dim uriReportSource = DirectCast(sourceReportSource, UriReportSource)
            Dim reportInstance = DeserializeReport(uriReportSource)
            ValidateReportSource(uriReportSource.Uri)
            Me.SetConnectionString(reportInstance)
            Return CreateInstanceReportSource(reportInstance, uriReportSource)

        Catch ex As Exception
            Glenfield.Common.HandleError(ex)

        End Try
    End Function
    Public Function DeserializeReport(uriReportSource As UriReportSource) As Report
        Dim m_Report As Telerik.Reporting.Report = New Telerik.Reporting.Report()
        Dim settings = New System.Xml.XmlReaderSettings()
        settings.IgnoreWhitespace = True
        Try
            Using xmlReader = System.Xml.XmlReader.Create(uriReportSource.Uri, settings)
                Dim xmlSerializer = New Telerik.Reporting.XmlSerialization.ReportXmlSerializer()
                Dim report = DirectCast(xmlSerializer.Deserialize(xmlReader), Telerik.Reporting.Report)
                m_Report = report
                Return m_Report
            End Using
        Catch ex As Exception
            Glenfield.Common.HandleError(ex)
        End Try
    End Function
    Public Sub ValidateReportSource(value As String)
        Try
            If value.Trim().StartsWith("=") Then
                Throw New InvalidOperationException("Expressions for ReportSource are not supported when changing the connection string dynamically")
            End If
        Catch ex As Exception
            Glenfield.Common.HandleError(ex)
        End Try
    End Sub
    Public Sub SetConnectionString(reportItemBase As ReportItemBase)
        Try
            Dim objectDataSource As New Telerik.Reporting.ObjectDataSource()
            objectDataSource.DataSource = CurrReport.m_CurrDataset
            objectDataSource.DataMember = "rptData"

            If reportItemBase.Items.Count < 1 Then
                Return
            End If

            If TypeOf reportItemBase Is Report Then
                Dim report = DirectCast(reportItemBase, Report)
                report.DataSource = objectDataSource

                'For Each item As Telerik.Reporting.ReportItemBase In reportItemBase.Items
                '    'recursively set the connection string to the items from the Items collection
                '    SetConnectionString(item)

                '    'set the drillthrough report connection strings
                '    Dim drillThroughAction = TryCast(item.Action, NavigateToReportAction)
                '    If drillThroughAction IsNot Nothing Then
                '        Dim updatedReportInstance = Me.SetUpReportSource(drillThroughAction.ReportSource)
                '        drillThroughAction.ReportSource = updatedReportInstance
                '    End If

                '    'Covers all data items(Crosstab, Table, List, Graph, Map and Chart)
                '    If TypeOf item Is DataItem Then
                '        Dim dataItem = DirectCast(item, DataItem)

                '        dataItem.DataSource = objectDataSource
                '        Continue For

                '    End If

                'Next

                For Each WkFItem As Microsoft.Reporting.WinForms.ReportParameter In CurrReport.ReportParameters

                    If report.ReportParameters.Contains(WkFItem.Name) Then
                        report.ReportParameters(WkFItem.Name).Value = WkFItem.Values(0)
                    End If

                Next

                report.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Custom
                report.PageSettings.Margins.Left = New Unit(0.25, UnitType.Inch)
                report.PageSettings.Margins.Right = New Unit(0.25, UnitType.Inch)
                report.PageSettings.Margins.Top = New Unit(0.25, UnitType.Inch)
                report.PageSettings.Margins.Bottom = New Unit(0.25, UnitType.Inch)

                If Glenfield.Globals.PaperSize = PrintPaperSize.Letter Then
                    If CurrReport.Orientation = PrintOrientation.Portrait Then
                        report.PageSettings.PaperSize = New SizeU(New Unit(11, UnitType.Inch), New Unit(8.5, UnitType.Inch))
                    Else
                        report.PageSettings.PaperSize = New SizeU(New Unit(8.5, UnitType.Inch), New Unit(11, UnitType.Inch))
                    End If

                    report.PageSettings.PaperKind = PaperKind.Letter
                Else
                    If CurrReport.Orientation = PrintOrientation.Portrait Then
                        report.PageSettings.PaperSize = New SizeU(New Unit(11.69, UnitType.Inch), New Unit(8.25, UnitType.Inch))
                    Else
                        report.PageSettings.PaperSize = New SizeU(New Unit(8.25, UnitType.Inch), New Unit(11.69, UnitType.Inch))
                    End If

                    report.PageSettings.PaperKind = PaperKind.A4
                End If

            End If
        Catch ex As Exception
            Glenfield.Common.HandleError(ex)
        End Try
    End Sub
    Private Function CreateInstanceReportSource(report As IReportDocument, originalReportSource As ReportSource) As ReportSource
        Dim instanceReportSource = New InstanceReportSource() With { _
    .ReportDocument = report _
}
        Try
            instanceReportSource.Parameters.AddRange(originalReportSource.Parameters)
        Catch ex As Exception
            Glenfield.Common.HandleError(ex)
        End Try
        Return instanceReportSource
    End Function

Stef
Telerik team
 answered on 20 Jul 2015
1 answer
202 views

Hello,

When I run a report telerik after making changes in the X-Axis Rotation Label to better fit them in the chart of type "Chart", the change isn't verified and returns to the default setting.

How is this possible? Is there any step that should follow?

I'm using 6.1.12.823 version of telerik reporting integrated with Visual Studio.

Best Regards,
Emídio Teixeira

Stef
Telerik team
 answered on 20 Jul 2015
1 answer
124 views

Hi Everyone

 

ASP MVC project.
I use Q1 2015 SP1 (9.0.15.324)
I have page with Html.TelerikReporting().ReportViewer()
There are parameters which user can set. I want to crate functionality which will send email with attached pdf report from this ReportViewer.
What the best way to implement this functionality? Could I export Report on HTML page array bytes (PDF) in JavaScript ?​

Stef
Telerik team
 answered on 20 Jul 2015
1 answer
104 views

Hi,

I need some help retrieving the active set report parameters from a web report viewer.

I have a aspx page with the report viewer on it, in addition to the viewer I also have a custom email button. When the user clicks on that button I would like to sent a mail with the current report as a attachment. Problem with that is that when the user changes a few report parameters I have to apply those changes to report before I create the PDF file.

The creation of the PDF file I'm doing with the report processor:

Dim reportProcessor As New Processing.ReportProcessor()
Dim deviceInfo As New Hashtable()
Dim instanceReportSource = reportViewer.ReportSource
Dim result As Processing.RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo)​

 Problem with the code above is that the parameters of the report viewer report source are the original parameters and not the ones who the user has changed.

 Anyone suggestions how I can send the displayed report as a PDF attachment in a mail?

 

Nasko
Telerik team
 answered on 20 Jul 2015
3 answers
72 views
I am trying to create a report that is structured like the attachment.   I have to fields Machine and Category that would be a header and then data pertaining to those 2 would be listed under.  Right now I have a sub report using a table.  I get the data from the DB and stuff into a datatable.any help is greatly appreciated. 
Nasko
Telerik team
 answered on 20 Jul 2015
1 answer
228 views

I am creating a Report in Hebrew, that means it is right to left.

 

I have now a Table that is in the following form

 

aa     bb   abc   x

aa     bb   def    x

aa     bb   ghi    x

cc     dd    jkl     y

cc     dd   mno  y

 

and what I would like to get is:

aa     bb   abc  x

                 def     

                 ghi     

cc     dd    jkl    y

                 mno

 

or at least:

aa     bb   abc   x
aa     bb   def    
aa     bb   ghi    
cc     dd    jkl     y
cc     dd   mno  

Is it possible with the standalone Report Designer to achieve something like that, and if yes how? Is there a way to change the groups from being added to the left side of the table, to be added to the right side?

Stef
Telerik team
 answered on 17 Jul 2015
1 answer
60 views

step 2:

Error Message:"
System.Web.Razor.Parser.TokenizerBackedParser~3[TTokenizer,TSymbol,TSymbolType]"上的GenericArgumnets[0]"
System.Web.Razor.Tokenzier.CSharpTokenizer“违反了类型”
TTokenizer“的约束。

 This is a screenshot!

 Have you an Idea to solve this ? Thank you.

 

Stef
Telerik team
 answered on 17 Jul 2015
3 answers
137 views
Hello All,


There are 4 parameters in my report from COO->VP-->region-->district, which designed in a cascading way.
I setup them all as "auto-refresh". In the first time, it works well.

If I choose Coo1, All for VP , all for region and all for district, once you finish choosing, the report is triggered to run. However, if after reports return, u re-choose a specific VP(VP1), the region and the district still stand as "all" and the report does not trigger to run.

Now, I wanna achieve like this, either the 2nd time I change my VP parameter, then reports can refresh or I change VP parameter then the downstream parameters can be back to "select a value" instead of standing as "ALL".

Who has any idea on this?
Thanks in advance. 

Nasko
Telerik team
 answered on 17 Jul 2015
4 answers
83 views

Here is my scenario:

 I have a report with multiple parameters, 2 of which are not working properly.  One of these parameters is called 'ParentOrg' and will return a list of all organizations.  The other is called 'Org' which takes the parameter value from 'ParentOrg' and makes sure that the same value is not included in the drop down list.

ParentOrg = (1,2,3,4,5,6)   and Org = (1,2,3,4,5,6)

But, when the report renders and I have chosen ParentOrg = 3, the Org drop down should only show/allow Org = (1,2,4,5,6).

The report will render with default values, but when I try to change the ParentOrg, the report crashes.

Can someone point me in the right direction?

 Thanks,

Phillip

Phil
Top achievements
Rank 1
 answered on 16 Jul 2015
1 answer
139 views
I've seen this question posted in years past but wanted to see if there's been any change to Telerik Reporting to facilitate adding a conditional page break based on report group page number to add a blank page for reports with odd page numbers.This is the only thing I've been able to find that is keeping us from converting to Telerik Reporting over Reporting Services. We mail reports out to thousands of people and need to be able to separate the reports for insertion into different envelopes, pretty hard when the first page of one person's report prints on the back of another person's. We do so much volume it just isn't an option to print on single sides. If anyone knows if this is now possible or of a work-around, I'd be interested in hearing it.
Stef
Telerik team
 answered on 16 Jul 2015
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?