Page 1 of 1

Error when open two or more reports in one

Posted: Tue Sep 17, 2019 1:50 pm
by Mateus Garrido Kern
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.

Re: Error when open two or more reports in one

Posted: Thu Sep 19, 2019 8:15 am
by Lech Kulikowski
Hello,

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

Thank you.

Re: Error when open two or more reports in one

Posted: Thu Sep 19, 2019 1:35 pm
by Mateus Garrido Kern
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.

Re: Error when open two or more reports in one

Posted: Sun Sep 22, 2019 4:07 pm
by Lech Kulikowski
Hello,

We need some time to investigate the issue.

Thank you.

Re: Error when open two or more reports in one

Posted: Mon Sep 23, 2019 11:50 am
by Mateus Garrido Kern
Hello,

I'm waiting for your return.

Thank you.

Re: Error when open two or more reports in one

Posted: Wed Sep 25, 2019 6:20 pm
by Lech Kulikowski
Hello,

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

Thank you.

Re: Error when open two or more reports in one

Posted: Mon Jul 20, 2020 1:00 pm
by Mateus Garrido Kern
Hello, I think this is the same error I posted in this post: viewtopic.php?f=27&t=58928

Re: Error when open two or more reports in one

Posted: Thu Jul 23, 2020 7:37 am
by Lech Kulikowski
Hello,

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

Thank you.