Telerik Forums
Reporting Forum
2 answers
684 views

I am having difficulty accessing report params on the backend in order to properly generate a report. I am able to generate a blank report. But the backend is not receiving the parameters from the angular tr-viewer

on the front I have a tr-viewer with params { MemberID: 59, Date: '3/31/2021', }

    #totalReport1
    [containerStyle]="viewerContainerStyle"
    [serviceUrl]="'http://localhost:1088/api/reportapi/'"
    [reportSource]="{
        report: 'ReportAssetAllocation',
        parameters: { MemberID: 59, Date: '3/31/2021' }
    }"
    [viewMode]="'INTERACTIVE'"
    [scaleMode]="'SPECIFIC'"
    [scale]="1.0"
    [ready]="ready"
    [viewerToolTipOpening]="viewerToolTipOpening"
    [enableAccessibility]="true"
>
</tr-viewer>

The report is generated in the C# constructor below

Please note that the way data is being fetched below was with a previous version of this application which used angularjs and took in the parameters through http headers.

    public partial class ReportAssetAllocation : Telerik.Reporting.Report
    {
        public int MemberID { get; set; }
        public string Date { get; set; }

        public ReportAssetAllocation()
        {
            try
            {
                if (HttpContext.Current.Request.Headers.GetValues("memberID") != null)
                {
                    MemberID = Convert.ToInt32(HttpContext.Current.Request.Headers.GetValues("memberID")[0]);                     
                    Date = Convert.ToString(HttpContext.Current.Request.Headers.GetValues("Date")[0]);
                }
            }
            catch { }

            InitializeComponent();
        }

I want to modify this constructor to accept the params from the Angular tr-viewer but I have not had any success in doing this after trying multiple methods from other posts and documentation.

What is best way to access these reportSource parameters { MemberID: 59, Date: '3/31/2021', } in my C# file?

 

 

For reference, here is the report api controller just in case:

  public class ReportApiController : ReportsControllerBase
    {
        static readonly ReportServiceConfiguration preservedConfiguration;

        static ReportApiController()
        {
            {
                var resolver = new UriReportSourceResolver(HttpContext.Current.Server.MapPath("~/Reports"))
                    .AddFallbackResolver(new TypeReportSourceResolver()
                        .AddFallbackResolver(new TypeReportSourceResolver()));

                preservedConfiguration = new ReportServiceConfiguration
                {
                    HostAppId = "REPORTS",
                    ReportSourceResolver = resolver,
                    Storage = new Telerik.Reporting.Cache.File.FileStorage(),
                };
                var assemblyName = typeof(ReportCatalog).AssemblyQualifiedName;
                var namespaceOfClass = typeof(ReportAssetAllocation).Namespace;
            }
        }

        public ReportApiController()
        {
            this.ReportServiceConfiguration = preservedConfiguration;
        }
    }

 

Thank you

Joel
Top achievements
Rank 1
Iron
 updated answer on 28 Jun 2021
1 answer
671 views

Hello,

When I tried to use 

            RenderingResult result = reportProcessor.RenderReport("XLSX", instanceReportSource, null);

The footer is not included in the excel. Why is that?

 

Thanks,

Arjay

Neli
Telerik team
 answered on 25 Jun 2021
1 answer
701 views

We use the Report Designer to design a report that we want to access through the browser.
Does the Telerik Report service support Linux installation? What if I could include a link in my reply?

 


Eric R | Senior Technical Support Engineer
Telerik team
 answered on 23 Jun 2021
1 answer
286 views

Here is my expression...

= IIF(ReportItem.Parent.DataObject.SoldtoAddress.CustKey = "ADEEL", "M3","") + Fields.RollID

As-is, the expression works. But, if the expression is false and I put anything in the empty quotes, the report won't run and gives the error, "Object reference not set to an instance of an object."

Am I doing something wrong? Thanks!

Plamen Mitrev
Telerik team
 answered on 23 Jun 2021
1 answer
350 views

Ok - pulled my hair out for a couple of days testing out the telerik reporting - the report works as expected, but I am trying to get report viewer object and update the parameters from some bootstrap controls, but just get the following:

Uncaught TypeError: viewer.reportSource is not a function
    at HTMLButtonElement.<anonymous> (ReportViewer?type=4:37)
    at HTMLButtonElement.dispatch (jquery-3.6.0.min.js:2)
    at HTMLButtonElement.v.handle (jquery-3.6.0.min.js:2)

I have hardcoded the parameters to try and test - what I have in the page so far is as follows (using MVC).
It looks like jQuery cant find the report viewer by its id - some help would be appreciated here please and yes the code is quick and dirty :)


@model Platform.Code.ReportParamters

@{
    Layout = null;
}

@{
    TypeReportSource typeReportSource = Model.ParamReportSource;
    typeReportSource.Parameters.Add(new Telerik.Reporting.Parameter("YardID", Model.ParamYardID));
    typeReportSource.Parameters.Add(new Telerik.Reporting.Parameter("StartDate", Model.ParamStartDate));
    typeReportSource.Parameters.Add(new Telerik.Reporting.Parameter("EndDate", Model.ParamEndDate));
    typeReportSource.Parameters.Add(new Telerik.Reporting.Parameter("MovementCategoryID", Model.ParamMovementCategory));
    typeReportSource.Parameters.Add(new Telerik.Reporting.Parameter("Username", Model.ParamUsername));
}



<link href="https://kendo.cdn.telerik.com/2018.2.620/styles/kendo.common.min.css" rel="stylesheet" />
<link href="https://kendo.cdn.telerik.com/2018.2.620/styles/kendo.blueopal.min.css" rel="stylesheet" />
<script src="~/Scripts/jquery-3.6.0.min.js"></script>
<script src="@Url.Content("~/api/reports/resources/js/telerikReportViewer")"></script>


<div class="row">
    <button type="button" id="updateReport" class="btn btn-primary">Primary</button>
</div>


@(
    Html.TelerikReporting().ReportViewer()
        .Id("reportViewer")
        .ServiceUrl("/api/reports/")
        .ReportSource(typeReportSource)
        .ViewMode(ViewMode.Interactive)
        .ScaleMode(ScaleMode.Specific)
        .Scale(1.0)
)



<script>
    $(document).ready(function () {
        $('#updateReport').on('click', function () {
            var viewer = $('#reportViewer').data('telerik_ReportViewer');
            viewer.reportSource({
                report: viewer.reportSource().report,
                parameters: {
                    YardID: 1,
                    StartDate: '2020-06-21T00:00:01',
                    EndDate: '2021-06-21T23:59:59',
                    MovementCategoryID: 3,
                    Username: 'David Smith'
                }
            });
            //setting the HTML5 Viewer's reportSource, causes a refresh automatically
            //if you need to force a refresh for other case, use:
            //viewer.refreshReport();
        });
    });
</script>

 

 

 

Neli
Telerik team
 answered on 23 Jun 2021
0 answers
316 views

Hai Telerik Team,

I was testing , the integration of  Telerik Reporting in my asp.net Core application.But when i load report from my html page , it shows an error , related to connection string not get properly , the error message is that

An error occurred while loading the data schema for "sqlDataSource1": Unable to establish a connection to the database. Please verify that your connection string is valid. In case you use a named connection string from the application configuration file, make sure the name is correct and the connection string settings are present in the configuration file of your application.

Report is loading from designer , using same connection string.When i  try to integrate telerik example reports, system shows same error message.

please give me your suggestion to how fixt this issue

 

 

Noufal
Top achievements
Rank 1
 asked on 22 Jun 2021
0 answers
898 views

I want to set up a conditional format to hide an image if the byte array count < 2. I cannot figure out how to simply deal with collections such as arrays and get a count.

I've tried this, but my report won't preview in the designer:

= Count(=Fields.[Logo])

How do I achieve this?

Thanks in advance.

Rick Feuer
Top achievements
Rank 1
 asked on 21 Jun 2021
1 answer
582 views
I have multiple tables that I would like to join together based on e.g. CustomerID. I know I could use a report parameter, which I already am using for the date. What I want to do is filter by the date report parameter, but align the table rows by the Customer ID in each table so it looks like a seamless report. Can I do this through binding?? If so, how?
Todor
Telerik team
 answered on 15 Jun 2021
1 answer
1.1K+ views

Goal: Change a trdx's web services data sources from using web service requests to using inline data strings and then render a PDF.

The trdx was created using the Invoice Report Wizard and has two data sources (one for header and one for detail). Both actually call the same web service method but use different data selectors ($.result and $.result.MemberReceiptDetails). I need to replace these calls with inline json strings (again, they'll be identical) and remove the parameters.  I see the Report class has a DataSource property but how does this relate to multiple datasources?.

 

            XmlReportSource reportSource = new XmlReportSource();

            Report report = GetReportFromResources("Member.DuesReceipt.trdx");

            //Change data sources here

            StringBuilder builder = new StringBuilder();
            using (System.Xml.XmlWriter xmlWriter = System.Xml.XmlWriter.Create(builder))
            {
                Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
                    new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();

                xmlSerializer.Serialize(xmlWriter, report);
            }

            reportSource.Xml = builder.ToString();

            var reportProcessor = new ReportProcessor();
            RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, null);

Dimitar
Telerik team
 answered on 15 Jun 2021
1 answer
813 views

Please refer the snapshot attached.

The telerikReportViewer.js file is not loading properly. I checked the path, its linked correctly (Refer Snapshot : telerikReportViewer1.png)

But still my reports are not loading properly.

It looks like its not about the file path, something else seems to be causing this error.

Please help.

Plamen Mitrev
Telerik team
 answered on 14 Jun 2021
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?