Telerik Forums
Reporting Forum
1 answer
751 views

I am using MVC report viewer along with asp.net mvc ui and I want to generate a report after an ajax call

here is my ajax

<script>
    function generateAccountsPayableReports() {
        var ms = $("#msInvoicesAPV").data("kendoMultiSelect");
        var invoices = ms.dataItems();
        var invoiceIds = [];

        invoices.forEach(function (invoice) {
            invoiceIds.push(invoice.Id);
        });

        $.ajax({
            type: "POST",
            url: "/APV/GenerateData ",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify({ 'invoiceIds': invoiceIds }),
            success: function (result) {
                if (result) {
                    console.log("Result: ", result);
                    var w = window.open();
                    $(w.document.body).html(result);
                }
            },
            failure: function (result) {
                console.error("result: ", result);
            },
            error: function (result) {
                console.error("result: ", result);
            }
        });
    }
</script>

and here is my controller action

        [HttpPost]
        public ActionResult GenerateReport(List<Guid> invoiceIds)
        {
            var apvReports = _reportsLogic.GenerateAccountPayableVouchers(invoiceIds);
            string json = JsonConvert.SerializeObject(apvReports);
            string reportSource = typeof(AccountsPayableVoucher).AssemblyQualifiedName + "--" + json;

            return View("CustomReportViewer", (object)reportSource);
        }

 

I tried initializing a new window and assigning the html to that window but if failed as you can see in my ajax call

                    var w = window.open();
                    $(w.document.body).html(result);

is there other way you could advise me to?

Neli
Telerik team
 answered on 22 Nov 2019
1 answer
799 views

I created a report library .dll to print reports ad-hoc with no previewing, so I can use it in a rest api. This has been working fine since installation over 4months ago.

I have just updated to v 13.2.19.1030, now when a report is trying to print is get the following error..

"The data area passed to a system call is too small"

I have copied and pasted my code below..

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

public void printPalletLabel(string palletBarcode, string courier, string printerName, short copies)
        {
            string reportName = _basePath + "\\Reports\\";

            try
            {
                // CREATE A REPORT INSTANCE FROM THE REPORT FILE
                switch (courier.ToUpper())
                {
                    case "DPD":
                        reportName += "palletLabel_DPD.trdp";
                        break;

                    case "YODEL":
                        reportName += "palletLabel_Yodel.trdp";
                        break;

                    default:
                        reportName += "palletLabel_UKMail.trdp";
                        break;
                }

                // REMOVE URI START IS EXISTS
                if (reportName.StartsWith("file:\\"))
                    reportName = reportName.Substring(6);

                var reportInstance = UnpackageReport(reportName);

                if (reportInstance != null)
                { 
                    // MODIFY CONNECTIONSTRING AND PASS PARAMETER
                    var ds = reportInstance.DataSource;

                    var sqlDataSource = (SqlDataSource)ds;
                    sqlDataSource.ConnectionString = _connectionString;
                    sqlDataSource.ProviderName = "System.Data.SqlClient";
                    sqlDataSource.Parameters["@palletBarcode"].Value = palletBarcode;
                        
                    printReport(reportInstance, printerName, copies);
                }
            }
            catch (Exception ex)
            {
                error = "reporting.printPalletLabel(): " + ex.Message;
            }

            
        }

        private void printReport(Telerik.Reporting.Report report, string printerName, short copies)
        {
            try
            {
                InstanceReportSource reportSource = new InstanceReportSource
                {
                    ReportDocument = report
                };


                // SET PRINTER
                var printerSettings = new System.Drawing.Printing.PrinterSettings
                {
                    PrinterName = printerName,
                    Copies = copies
                };

                // PRINT REPORT
                var reportProcessor = new ReportProcessor();
                reportProcessor.PrintReport(reportSource, printerSettings);
            }
            catch (Exception ex)
            {
                error = "reporting.printReport(): " + ex.Message;
            }
        }
        private Telerik.Reporting.Report UnpackageReport(string reportName)
        {
            var reportPackager = new ReportPackager();

            try
            {
                using (var sourceStream = System.IO.File.OpenRead(reportName))
                {
                    var report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
                    return report;
                }
            }
            catch (Exception ex)
            {
                error = "reporting.UnpackageReport(): " + ex.Message;
                return null;
            }
        }

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

The error occurs at the following line within printReport()

reportProcessor.PrintReport(reportSource, printerSettings); 

 

Any ideas?

 

Thanks 

Andy

 

Andrew
Top achievements
Rank 1
 answered on 22 Nov 2019
1 answer
653 views

 I have function and procedure in database PostgreSqL but can't create connection string for PostgreSQL. 

 

Eric R | Senior Technical Support Engineer
Telerik team
 answered on 19 Nov 2019
9 answers
512 views

I have created .NET Solution which one use the three layers architecture (DAL: APM.DataAccess, BR: APM.BusinessRules, UI: APM (MVC Web Project)), also I have created a reporting based on class .cs (into APM web layer), I mean compiled report (not standalone).  I have created the methods to retrieve data through different layers into my .NET solution.  At the end I want to include an ObjectDataSource (because the data retrieved from different Layer needs be processing in order to complete and show in report) into my compiled report but I can't see the main namespace APM (web layer) which contains my method to retrieve data processed in order to display on the report.   So when I add the ObjectDataSource into report layout, I can see the popup window where I can choose the Namespace and select the method to retrieve data, but here I can't see APM namespaces and I can't choose the right method.  Do you have any idea or comments about it? I attached some images.

I am using the Telerik_Reporting_R3_2016_SP1_10_2_16_1025_DEV.msi

Darrin
Top achievements
Rank 1
 answered on 17 Nov 2019
1 answer
167 views

I upgraded to to latest software version and now I can't get a Telerik Report to render to save my life.  The page is very simple.

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="ReportViewerForm1.aspx.vb" Inherits="trvTest._ReportViewerForm1" %>
 
<%@ Register TagPrefix="telerik" Assembly="Telerik.ReportViewer.Html5.WebForms" Namespace="Telerik.ReportViewer.Html5.WebForms" %>
 
<!DOCTYPE html>
<head runat="server">
    <title>Telerik HTML5 Web Forms Report Viewer Form</title>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
 
    <style>
        #reportViewer1 {
            position: absolute;
            left: 5px;
            right: 5px;
            top: 5px;
            bottom: 5px;
            overflow: hidden;
            font-family: Verdana, Arial;
        }
    </style>
 
</head>
<body>
    <form runat="server">
        <telerik:ReportViewer
            ID="reportViewer1" ServiceUrl="http://localhost/TReportServer/api/reports"
            Width="1300px"
            Height="900px"
            runat="server">
            <ReportSource IdentifierType="UriReportSource" Identifier="POSInvoice.trdp">
            </ReportSource>
            <%-- If set to true shows the Send Mail Message toolbar button --%>
            <SendEmail Enabled = "false" />
        </telerik:ReportViewer>
    </form>
</body>
</html>

 

When I run it.  The page looks like the attached screen print.  It has numerous java errors most of which seem to have something to do with Kendo and as far as I know I'm not even using Kendo.  

Nasko
Telerik team
 answered on 15 Nov 2019
6 answers
235 views

Hello,

I have a regular report in my asp.net core 2.2 with 1 picturebox and 3 checkboxs. Works #1.

I create a new asp.net core 3.0 (copying everything from 2.2).  My picturebox and the 3 squares of the checkboxs (but the labels are ok) are not anymore display in the reportViewer (javascript).  When i generate a PDF version everthing worked.

Telerik.Reporting v13.2.19.920-hotfix (same problem with 13.2.19.918)
Telerik.Reporting.Services.AspNetCore  v13.2.19.920-hotfix (same problem with 13.2.19.918)

Any idea? 

Ivan Hristov
Telerik team
 answered on 15 Nov 2019
1 answer
266 views

Hi,

I need to use WebServiceDataSource to connect to a web service with Windows Authentication. Is it possible to do that?

 

Regards,

Nasko
Telerik team
 answered on 15 Nov 2019
3 answers
1.0K+ views

I have the report that contains a table to show some payment information, and underneath there is textBox to show sum of PaymentAmount property values.

See attached sample report image to see. The report has jsonDataSource and it has collection property of "PaymentLinks" which has 4 items and each item of the collection has "PaymentAmount" integer value. The table is showing "PaymentAmount" property value. 

I have to calculate sum of "PaymentAmount" column and set the result in TextBox next to "TotalPaymentAmount:". How should I do that?

FYI: If you right click on the table last row, you can see "Add Total" on the context menu. Maybe we can use this to sum of the column values?

The jsonDataSource contains this inline JSON:

{            
     "TotalLinksAmount": 10,       
     "PaymentLinks": [
        {                   
             "PaymentAmount": 10         
        },
        {               
             "PaymentAmount": 100       
        },
        {
             "PaymentAmount": 25     
        },
         {
             "PaymentAmount": 30     
        }

     ]
}  

Neli
Telerik team
 answered on 14 Nov 2019
3 answers
164 views

Hi.

I'm using the standaloneTelerik Report Designer to create a report with a table control.  I set the property ColumnHeadersPrintOnEveryPage=true for the table to display the header on each page.  It works as required when I export to PDF, but when I export to Excel (XLSX) the column header does not freeze and disapears when scrolling down.

It looks like a bug to me but can you advice if not ?

Best regards,
Kalli

Eric R | Senior Technical Support Engineer
Telerik team
 answered on 13 Nov 2019
3 answers
341 views

Where can I get the url for the subreports?

I have been trying to use

localhost:83/Report/View/Monthly%20Reports/Monthly%20CDR%20Report%20Excel

But that does not work.

 

Neli
Telerik team
 answered on 13 Nov 2019
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?