Error when open two or more reports in one

Stimulsoft Reports.JS discussion
Post Reply
Mateus Garrido Kern
Posts: 29
Joined: Wed Sep 04, 2019 5:19 pm
Location: Curitiba/PR (Brazil)

Error when open two or more reports in one

Post by Mateus Garrido Kern » Tue Sep 17, 2019 1:50 pm

Hello, I have an error when I open three reports in on, in a merge way in a Angular 7 project.

When I will open a first page of second report I have this Error:

Code: Select all

[color=#FF0000]ERROR TypeError: Cannot read property 'sortingEnabled' of null[/color]
My code in the TypeScript side:

Code: Select all

const reportTermoAbertura = new Stimulsoft.Report.StiReport();
      reportTermoAbertura.loadFile('../../../assets/ReportTermoAberturaEncerramento.mrt');
      reportTermoAbertura.isAsync = true;

      const reportLivroDiario = new Stimulsoft.Report.StiReport();
      reportLivroDiario.loadFile('../../../assets/ReportLivroDiario.mrt');
      reportLivroDiario.isAsync = true;

      const reportTermoEncerramento = new Stimulsoft.Report.StiReport();
      reportTermoEncerramento.loadFile('../../../assets/ReportTermoAberturaEncerramento.mrt');
      reportTermoEncerramento.isAsync = true;

      this.preencherEmpresaId();

      const reportMerge = new Stimulsoft.Report.StiReport();
      reportMerge.reportUnit = reportLivroDiario.reportUnit;
      reportMerge.render();
      reportMerge.renderedPages.clear();

      const dbJsonAbertura = reportTermoAbertura.dictionary.databases.getByName('JSON');
      dbJsonAbertura.pathData =
          'https://localhost:44347/api/relatorio/TermoAberturaDiario?EmpresaId=' + this.empresaId +
          '&EstabelecimentoId=' + this.estabelecimentoId + '&NumeroLivro=' + '1' +
          '&DataEmissao=' + '13/09/2019' + '&DataEncerramentoExercicioSocial=' + '01/05/2019' +
          '&DataPeriodoEscrituracaoInicio=' + this.dataInicial.toLocaleDateString() +
          '&DataPeriodoEscrituracaoFinal=' + this.dataFinal.toLocaleDateString();

      const dbLivroDiario = reportLivroDiario.dictionary.databases.getByName('LivroDiario');
      dbLivroDiario.pathData =
          'https://localhost:44347/api/relatorio/LivroDiario?DataInicio=' + this.dataInicial.toLocaleDateString() +
          '&DataFim=' + this.dataFinal.toLocaleDateString() + '&EstabelecimentoId=' + this.estabelecimentoId +
          '&EmpresaId=' + this.empresaId + '&QuebraPorMes=' + this.quebraMes;

      this.impressaoContasEscolhidas.forEach(tipoImpressao => {
        dbLivroDiario.pathData += '&' + tipoImpressao + '=true';
      });

      const dbJsonEncerramento = reportTermoEncerramento.dictionary.databases.getByName('JSON');
      dbJsonEncerramento.pathData =
          'https://localhost:44347/api/relatorio/TermoEncerramentoDiario?EmpresaId=' + this.empresaId +
          '&EstabelecimentoId=' + this.estabelecimentoId + '&NumeroLivro=' + '1' +
          '&DataEmissao=' + '13/09/2019' + '&DataEncerramentoExercicioSocial=' + '01/05/2019' +
          '&DataPeriodoEscrituracaoInicio=' + this.dataInicial.toLocaleDateString() +
          '&DataPeriodoEscrituracaoFinal=' + this.dataFinal.toLocaleDateString();

      reportTermoAbertura.renderAsync(function () {
        for (let index = 0; index < reportTermoAbertura.renderedPages.count; ++index) {
            reportMerge.renderedPages.add(reportTermoAbertura.renderedPages.getByIndex(index));
        }
      });

      reportLivroDiario.renderAsync(function () {
        for (let index = 0; index < reportLivroDiario.renderedPages.count; ++index) {
            reportMerge.renderedPages.add(reportLivroDiario.renderedPages.getByIndex(index));
        }
      });

      reportTermoEncerramento.renderAsync(function () {
        for (let index = 0; index < reportTermoEncerramento.renderedPages.count; ++index) {
            reportMerge.renderedPages.add(reportTermoEncerramento.renderedPages.getByIndex(index));
        }

        reportMerge.renderedPages.list.forEach(function(page, i, arr) {
          const paginacao = page.components.getByName('Paginacao');
          if (paginacao) {
            paginacao.text = 'Página ' + (i + 1) + ' de ' + reportMerge.renderedPages.count;
          }

          const textoCentral = page.components.getByName('TextoCentral');
          if (textoCentral) {
            textoCentral.text = textoCentral.text.replace(/{NumeroFolhas}/gi, '' + reportMerge.renderedPages.count);
          }
        });
      });

      this.viewer.report = reportMerge;
      this.viewer.renderHtml('viewer');

Would you have any solution for this error? Thanks.
Attachments
erro.PNG
Error that appears.
erro.PNG (47.14 KiB) Viewed 1157 times
Mateus Garrido Kern
Email: desenv5.digibyte@outlook.com
Lech Kulikowski
Posts: 3314
Joined: Tue Mar 20, 2018 5:34 am

Re: Error when open two or more reports in one

Post by Lech Kulikowski » Thu Sep 19, 2019 8:15 am

Hello,

Please send us a sample report with test data which reproduces the issue for analysis.

Thank you.
Mateus Garrido Kern
Posts: 29
Joined: Wed Sep 04, 2019 5:19 pm
Location: Curitiba/PR (Brazil)

Re: Error when open two or more reports in one

Post by Mateus Garrido Kern » Thu Sep 19, 2019 1:35 pm

I couldn't send the compact project because of the size of it.

I sending the reports separately with the JSON Mocks.

In the project, I used Angular 7, I create a component and I put this code in the TypeScript side:

Code: Select all

import { Component, OnInit } from '@angular/core';
import { ViewEncapsulation } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';

declare var Stimulsoft: any;

@Component({
    selector: 'app-root',
    template: `<div>
					<h2>Stimulsoft Reports.JS - MockTest_ReportLivroDiario.mrt - Viewer</h2>
					<div id="viewerContent"></div>
				</div>`,
    encapsulation: ViewEncapsulation.None
})

export class AppComponent implements OnInit {
    options: any = new Stimulsoft.Viewer.StiViewerOptions();
    viewer: any = new Stimulsoft.Viewer.StiViewer(this.options, 'StiViewer', false);

    ngOnInit() {
        const reportTermoAbertura = new Stimulsoft.Report.StiReport();
        reportTermoAbertura.loadFile('reports/MockTest_ReportTermoAbertura.mrt');

        const reportLivroDiario = new Stimulsoft.Report.StiReport();
        reportLivroDiario.loadFile('reports/MockTest_ReportLivroDiario.mrt');

        const reportTermoEncerramento = new Stimulsoft.Report.StiReport();
        reportTermoEncerramento.loadFile('reports/MockTest_ReportTermoEncerramento.mrt');

        const reportMerge = new Stimulsoft.Report.StiReport();
        reportMerge.reportUnit = reportLivroDiario.reportUnit;
        reportMerge.render();
        reportMerge.renderedPages.clear();

        reportTermoAbertura.renderAsync(function () {
            for (let index = 0; index < reportTermoAbertura.renderedPages.count; ++index) {
                reportMerge.renderedPages.add(reportTermoAbertura.renderedPages.getByIndex(index));
            }
        });

        reportLivroDiario.renderAsync(function () {
          for (let index = 0; index < reportLivroDiario.renderedPages.count; ++index) {
            reportMerge.renderedPages.add(reportLivroDiario.renderedPages.getByIndex(index));
          }
        });

          reportTermoEncerramento.renderAsync(function () {
            for (let index = 0; index < reportTermoEncerramento.renderedPages.count; ++index) {
                reportMerge.renderedPages.add(reportTermoEncerramento.renderedPages.getByIndex(index));
            }

            reportMerge.renderedPages.list.forEach(function(page, i, arr) {
              const paginacao = page.components.getByName('Paginacao');
              if (paginacao) {
                paginacao.text = 'Página ' + (i + 1) + ' de ' + reportMerge.renderedPages.count;
              }

              const textoCentral = page.components.getByName('TextoCentral');
              if (textoCentral) {
                textoCentral.text = textoCentral.text.replace(/{NumeroFolhas}/gi, '' + reportMerge.renderedPages.count);
              }
            });
          });

        this.viewer.report = reportMerge;
        this.viewer.renderHtml('viewerContent');
    }

    constructor(private http: HttpClientModule) {

    }
}

And in the reports I edited the line 116, called the right way JSON.

Thank you.
Attachments
MockTest_ReportTermoEncerramento.json
(876 Bytes) Downloaded 56 times
MockTest_ReportTermoAbertura.json
(875 Bytes) Downloaded 63 times
MockTest_ReportLivroDiario.json
(10.57 KiB) Downloaded 64 times
MockTest_ReportTermoEncerramento.mrt
(26.28 KiB) Downloaded 62 times
MockTest_ReportTermoAbertura.mrt
(26.28 KiB) Downloaded 68 times
MockTest_ReportLivroDiario.mrt
(20.7 KiB) Downloaded 57 times
Mateus Garrido Kern
Email: desenv5.digibyte@outlook.com
Lech Kulikowski
Posts: 3314
Joined: Tue Mar 20, 2018 5:34 am

Re: Error when open two or more reports in one

Post by Lech Kulikowski » Sun Sep 22, 2019 4:07 pm

Hello,

We need some time to investigate the issue.

Thank you.
Mateus Garrido Kern
Posts: 29
Joined: Wed Sep 04, 2019 5:19 pm
Location: Curitiba/PR (Brazil)

Re: Error when open two or more reports in one

Post by Mateus Garrido Kern » Mon Sep 23, 2019 11:50 am

Hello,

I'm waiting for your return.

Thank you.
Mateus Garrido Kern
Email: desenv5.digibyte@outlook.com
Lech Kulikowski
Posts: 3314
Joined: Tue Mar 20, 2018 5:34 am

Re: Error when open two or more reports in one

Post by Lech Kulikowski » Wed Sep 25, 2019 6:20 pm

Hello,

We are working on the problem, we will let you know about the result.

Thank you.
Mateus Garrido Kern
Posts: 29
Joined: Wed Sep 04, 2019 5:19 pm
Location: Curitiba/PR (Brazil)

Re: Error when open two or more reports in one

Post by Mateus Garrido Kern » Mon Jul 20, 2020 1:00 pm

Hello, I think this is the same error I posted in this post: viewtopic.php?f=27&t=58928
Mateus Garrido Kern
Email: desenv5.digibyte@outlook.com
Lech Kulikowski
Posts: 3314
Joined: Tue Mar 20, 2018 5:34 am

Re: Error when open two or more reports in one

Post by Lech Kulikowski » Thu Jul 23, 2020 7:37 am

Hello,

We are working on the problem, we will let you know about the result.

Thank you.
Post Reply