Telerik Forums
Reporting Forum
5 answers
1.8K+ views

Hi,

I'm using below code to generate report on run time:

using (ReportBook reportBook = new ReportBook())
            {
                foreach (Object input in inputValues)
                {
                    InstanceReportSource reportSource = new InstanceReportSource
                    {
                        ReportDocument = new MyReport
                        {
                            DataSource = new JsonDataSource
                            {
                                Name = "jsonDataSource1",
                                Source = genJsonDataSource(input)  // get json string from input object
                            }
                        }
                    };
                    reportBook.ReportSources.Add(reportSource);
                }
 
                ReportProcessor reportProcessor = new ReportProcessor();
                InstanceReportSource instanceReportSource = new InstanceReportSource
                {
                    ReportDocument = reportBook
                };
                RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, new System.Collections.Hashtable());
                // save report file from result
......
            }

 

MyReport is a c# report class created by visual studio designer. It is designed with a json datasource named "jsonDataSource1" with some sample data in it. The report is generated as PDF but error is shown as in attached screenshot. I followed the instructions in https://docs.telerik.com/reporting/knowledge-base/missing-assembly-reference-when-using-jsondatasource by referencing Telerik.Reporting.WebServiceDataSource.dll in my project and make sure it's exist in the running directory. But the error persists. And when the dll is not referenced, I can preview the report without problem. So the symptom seems not exactly same as the document describes. The dll version is 14.2.20.1021. .Net 4.8.

What else need be done to fix this error?

Randy
Top achievements
Rank 1
Veteran
 answered on 24 Dec 2020
3 answers
720 views
I am moving a report from SSRS to Telerik due to better support for HTML fields in Telerik.

I have a table, and I want it to appear like:

Table Header
Group Header
Data

However, in using Telerik Reporting, I don't seem able to achieve this. It seems that the best I can do is:

Group Header
Table Header
Data

Based on the below screenshot (currenttelerikreport.png) - I would think I could "just" add a new group header row and add my table header columns, but I'm unable to split the cells. I don't know if the multiple merged cells are causing a problem or what. 

Any ideas?
Nasko
Telerik team
 answered on 24 Dec 2020
1 answer
549 views

The text-transform: capitalize syntax is perfectly working when viewing in design tab of Htmlbox , but whenever I printpreview the report , the syntax is not working.

I provided some screenshots regarding to this issue, hope someone could help me out ,really need this feature so that I can use the capitalize text form.
Thanks in Advance.

Dimitar
Telerik team
 answered on 23 Dec 2020
7 answers
3.6K+ views
I'm trying to find the best way to get a count of rows returned from the data source? I'm trying to put this in a text box. Is there something like =DataSource.Count ?
Mads
Telerik team
 answered on 23 Dec 2020
1 answer
330 views

I am programmatically generating a PDF from a TRDP file which uses an ObjectDataSource.  When I preview my report using default values in the standalone report designer, the data is displayed correctly.  When I set the parameters programatically and render the report in code, no data is displayed.  Here is the code to generate the PDF.  Appreciate any help.

Telerik.Reporting.UriReportSource reportSource =
    new Telerik.Reporting.UriReportSource
    {
        Uri = "Reports\\MyReport.trdp"
    };
 
reportSource.Parameters.Add(new Telerik.Reporting.Parameter("batchId", batchId));
reportSource.Parameters.Add(new Telerik.Reporting.Parameter("accession", accession));
 
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
 
var result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);

 

Tony
Top achievements
Rank 1
 answered on 22 Dec 2020
1 answer
328 views

Hello. I am posting a question like this because I keep getting errors while using the report.

This problem only occurs on the project I am currently working on.

"An exception of type 'System.NullReferenceException' occurred in

PresentationFramework.dll but was not handled in user code Additional information

: Object reference not set to an instance of an object."

 

When creating a new project with the same reference, no error appears.

What is the problem? Leave the sauce below.

 

Telerik 2020.3.915.40 Version References(7)

Telerik.Windows.Controls Telerik.Windows.Controls.Chart Telerik.Windows.Controls.Data Telerik.Windows.Controls.GridView

Telerik.Windows.Controls.Input Telerik.Windows.Controls.Navigation Telerik.Windows.Data

 

TelerikReporting 14.2.20.916 Version References(5)

Telerik.Reporting Telerik.Reporting.OpenXmlRendering Telerik.Reporting.OpenXmlRendering Telerik.ReportViewer.Wpf Telerik.ReportViewer.Wpf.Themes

 

 

=Xaml======================================================================================

<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/SKC_QTO;component/Plugin/Themes/Report/System.Windows.xaml" />
<ResourceDictionary Source="pack://application:,,,/SKC_QTO;component/Plugin/Themes/Report/Telerik.Windows.Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/SKC_QTO;component/Plugin/Themes/Report/Telerik.Windows.Controls.Input.xaml" />
<ResourceDictionary Source="pack://application:,,,/SKC_QTO;component/Plugin/Themes/Report/Telerik.Windows.Controls.Navigation.xaml" />
<ResourceDictionary Source="pack://application:,,,/SKC_QTO;component/Plugin/Themes/Report/Telerik.ReportViewer.Wpf.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>


<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button x:Name="ChangeReportButton" Grid.Row="0" Height="30" Width="100" Command="{Binding ThisCommand}" Content="Change Report" Margin="0,0,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" >
</Button>
<tr:ReportViewer Grid.Row="1" x:Name="ReportViewer1" HorizontalAlignment="Stretch" ReportSource="{Binding MyReportSource}">
</tr:ReportViewer>

</Grid>

 

=Xaml.cs======================================================================================

    public partial class ReportingView : Window
    {
        internal const string TelerikVersion = "2020.3.915.40";
        internal const string TelerikPublicKeyToken = "~~~~~~~~~~";
        internal const string Culture = "~~~~~~";
        public ReportingView()
        {

          // This is for testing purposes. Assembly is initially registered at startup. 
            Assembly.Load($"Telerik.Windows.Controls,            Version={TelerikVersion}, Culture={Culture}, PublicKeyToken={TelerikPublicKeyToken}");
            Assembly.Load($"Telerik.Windows.Controls.Chart,      Version={TelerikVersion}, Culture={Culture}, PublicKeyToken={TelerikPublicKeyToken}");
            Assembly.Load($"Telerik.Windows.Controls.Data,       Version={TelerikVersion}, Culture={Culture}, PublicKeyToken={TelerikPublicKeyToken}");
            Assembly.Load($"Telerik.Windows.Controls.GridView,   Version={TelerikVersion}, Culture={Culture}, PublicKeyToken={TelerikPublicKeyToken}");
            Assembly.Load($"Telerik.Windows.Controls.Input,      Version={TelerikVersion}, Culture={Culture}, PublicKeyToken={TelerikPublicKeyToken}");
            Assembly.Load($"Telerik.Windows.Controls.Navigation, Version={TelerikVersion}, Culture={Culture}, PublicKeyToken={TelerikPublicKeyToken}");
            Assembly.Load($"Telerik.Windows.Data,                Version={TelerikVersion}, Culture={Culture}, PublicKeyToken={TelerikPublicKeyToken}");

            InitializeComponent();   <<<<< This Error ★★★★★★★★★★
            this.DataContext = new ViewModel();
            //DataContext = new ReportingViewModel();
        }
    }

=ViewModel.cs======================================================================================

class ViewModel : INotifyPropertyChanged
    {
        private int testCounter = 0;


        public event PropertyChangedEventHandler PropertyChanged;
        Telerik.Reporting.ReportSource _myReportSource;

        public Telerik.Reporting.ReportSource MyReportSource
        {
            get { return this._myReportSource; }
            set
            {
                if (this._myReportSource != value)
                {
                    this._myReportSource = value;
                    if (null != this.PropertyChanged)
                    {
                        this.PropertyChanged(this, new PropertyChangedEventArgs("MyReportSource"));
                    }
                }
            }
        }

        public ViewModel()
        {

            this.MyReportSource = new InstanceReportSource { ReportDocument = null };

            _thisCommand = new Telerik.Windows.Controls.DelegateCommand(x => ChangeReport());

        }

        ICommand _thisCommand;
        public ICommand ThisCommand
        {
            get
            {
                return _thisCommand;
            }
        }

        public void ChangeReport()
        {
            if (testCounter % 2 == 1)
                this.MyReportSource = new InstanceReportSource { ReportDocument = new Report1() };
            else
                this.MyReportSource = new InstanceReportSource { ReportDocument = null };
            testCounter++;
        }

============================================================================================

 

Thanks.

Neli
Telerik team
 answered on 21 Dec 2020
4 answers
1.1K+ views

 

 

Currently running version R1 2020 SP1 (14.0.20.219) with the HTML 5 report viewer and the REST service ASP.NET Core 3.1

I am trying to set the database connection string dynamically using the method outlined in the knowledge base article below which passes it as a report parameter.

Change Connection String dynamically through a report parameter

 

This approach should be fine, however the issue is that I cannot find a way to modify the report parameters so that the connection string can be passed in.

 

I have tried to define a custom report resolver like the example below which adds the parameter to the report source.  But I am finding that the parameter value does not get passed into the report.

 

 

 

We are using .trdp files as our report source and I have seen some examples where people have unpacked the file to return an InstanceReportSource. By doing this it might be possible to set the parameters against the report object directly. 

Can anyone suggest a better way to set report parameters within the REST service (ie without passing the parameters from the client)?

 

 

 

 

Thanks

Andrew

 

public class CustomReportResolver : ReportFileResolver
{
    private readonly IDdrConnectionService _ddr;
    private readonly IHttpContextAccessor _httpContextAccessor;
 
    public CustomReportResolver(IDdrConnectionService ddr,
        IHttpContextAccessor httpContextAccessor,
        string repositoryDirectory) : base(repositoryDirectory)
    {
        _ddr = ddr;
        _httpContextAccessor = httpContextAccessor;
    }
 
    protected override ReportSource ResolveReport(string report)
    {
        ReportSource reportSource = base.ResolveReport(report);
 
        Guid tenantId = _httpContextAccessor.HttpContext.User.GetTenantId();
        string connString = _ddr.GetShardConnectionString(tenantId);
        reportSource.Parameters.Add("ConnectionString", connString);
 
        return reportSource;
    }
}

 

Andrew
Top achievements
Rank 1
 answered on 19 Dec 2020
6 answers
395 views

Hello,

I'm currently facing a problem with Telerik Reporting menus in Visual Studio 2019.

Last week I've created some reports, all was working well.

 

Today, I had to modify some of them but report files are not displaying icons of reports but of c# code.

When right clicking on my reports I don't have designer menu anymore (View designer menu).

 

What's really strange is that on other older reports, I still have this menu available and can view the designer.

 

I havent installed VS update

I tried to reinstall Telerik reporting package on my machine

Nothing changes.

 

The fact is that there is a difference between old reports and the one I created last week that make the first ones editable and the last ones not.

Do you know where I could search to find this difference that would make me able to edit them again please ? 

 

Thanks

Regards

Admin
Top achievements
Rank 1
 answered on 18 Dec 2020
1 answer
668 views

Hello, I am getting:

    "Unable to get report parameters.
    An error has occurred.
    Object reference not set to an instance of an object."

when trying to load a report into the HTML5 report viewer.

Code snippets below - resolve nevere gets called, but the payload of the POST looks correct.  Any ideas?

 

<script type="text/javascript">
    $(document).ready(function () {
            $("#reportViewer1")
                .telerik_ReportViewer({
                    // The URL of the service which will serve reports.
                    // The URL corresponds to the name of the controller class (ReportsController).
                    // For more information on how to configure the service please check http://www.telerik.com/help/reporting/telerik-reporting-rest-conception.html.
                    serviceUrl: "/reportdata/",
 
                    // The URL for the report viewer template. The template can be edited -
                    // new functionalities can be added and unneeded ones can be removed.
                    // For more information please check http://www.telerik.com/help/reporting/html5-report-viewer-templates.html.
                    // templateUrl: 'ReportViewer/templates/telerikReportViewerTemplate.html',
 
                    //ReportSource - report description
                    reportSource: {
 
                        // The report can be set to a report file name (.trdx or .trdp report definition)
                        // or CLR type name (report class definition).
                        report: { reportId: 89 },
 
                        // Parameters name value dictionary
                        parameters: { foo: 1}
                    },
 
 
 
                    //parameters: {
                    //    editors: {
                    //        singleSelect: telerikReportViewer.ParameterEditorTypes.COMBO_BOX,
                    //        multiSelect: telerikReportViewer.ParameterEditorTypes.COMBO_BOX,
                    //    }
                    //},
 
                    // Specifies whether the viewer is in interactive or print preview mode.
                    // PRINT_PREVIEW - Displays the paginated report as if it is printed on paper. Interactivity is not enabled.
                    // INTERACTIVE - Displays the report in its original width and height without paging. Additionally interactivity is enabled.
                    viewMode: telerikReportViewer.ViewModes.INTERACTIVE,
 
                    // Sets the scale mode of the viewer.
                    // Three modes exist currently:
                    // FIT_PAGE - The whole report will fit on the page (will zoom in or out), regardless of its width and height.
                    // FIT_PAGE_WIDTH - The report will be zoomed in or out so that the width of the screen and the width of the report match.
                    // SPECIFIC - Uses the scale to zoom in and out the report.
                    scaleMode: telerikReportViewer.ScaleModes.SPECIFIC,
 
                    // Zoom in and out the report using the scale
                    // 1.0 is equal to 100%, i.e. the original size of the report
                    scale: 1.0,
 
                    //Enables or disables the accessibility features of the report viewer and its contents.
                    enableAccessibility: false,
 
                    //If set to true shows the Send Mail Message toolbar button
                    sendEmail: { enabled: true }
                });
 
    });
    </script>

 

public class ReportSourceResolver : IReportSourceResolver
    {
        private string _reportDbConnectionString;
 
 
        public ReportSourceResolver(string reportDbConnectionString)
        {
            _reportDbConnectionString = reportDbConnectionString;
        }
 
        public Telerik.Reporting.ReportSource Resolve(string reportId,OperationOrigin operationOrigin, IDictionary<string, object> currentParameterValues)
        {
 
            sproc_ReportDetailsXMLGet_Wrapper.In_Type inparams = new sproc_ReportDetailsXMLGet_Wrapper.In_Type()
            {
                ReportId = reportId.ToNullableInt(),
            };
 
            var sp = new sproc_ReportDetailsXMLGet_Wrapper(inparams);
            _ = ReportingDB.ExecOn(_reportDbConnectionString).SpCall(sp);
 
            var outrecord = sp.Out.Records[0];
            return new Telerik.Reporting.XmlReportSource { Xml = outrecord.SerializedReport };
        }
    }
}

 

Neli
Telerik team
 answered on 17 Dec 2020
1 answer
231 views
I am having a text box inside the details section of my report. Value for this text box is passed by the data source during runtime. This report is rendered as a pdf. I don't want the text box to wrap the content, so right now I am using the character count (to determine if it wraps) to show or hide the text box. I would like to know if there is a way to identify if the text inside the box is wrapped after rendered as a pdf?
Todor
Telerik team
 answered on 17 Dec 2020
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?