Override Components

Stimulsoft Reports.JS discussion
Post Reply
User avatar
rafaelwithoeft
Posts: 70
Joined: Thu Mar 05, 2015 8:26 pm

Override Components

Post by rafaelwithoeft »

Hello, it's possible to override components like this code written in java?

Code: Select all

//Load report by xml
InputStream stream = new ByteArrayInputStream(relatorioXmlString.getBytes(StandardCharsets.UTF_8));
StiReport relatorioNovo = StiSerializeManager.deserializeReport(stream);
StiPageFooterBand bandaRodapeNova = (StiPageFooterBand) relatorioNovo.getComponents().get(nomeComponente);

/**
 * if has custom component
 */
if (bandaRodapeNova != null) {
	/**
	 * remove component
	 */
	int indiceComponenteOriginal = bandaRodapeOriginal.getPage().getComponents().indexOf(bandaRodapeOriginal);
	bandaRodapeOriginal.getPage().getComponents().remove(indiceComponenteOriginal);
	
	/**
	 * append new component
	 */
    bandaRodapeNova.setPage(relatorioOriginal.getPages().get(0));
    bandaRodapeNova.setName(nomeComponente);
    relatorioOriginal.getPages().get(0).getComponents().add(indiceComponenteOriginal, bandaRodapeNova);
    for (StiComponent componente : bandaRodapeNova.getComponents()) {
        componente.setPage(relatorioOriginal.getPages().get(0));
        componente.setParent(bandaRodapeNova);
        componente.setName(StiNameCreation.createName(relatorioOriginal, componente.getName().replaceAll("\\d*", "")));
    }
}
Best Regards
Andrew
Posts: 4108
Joined: Fri Jun 09, 2006 3:58 am

Re: Override Components

Post by Andrew »

Hello,

Thank you for the question.

Yes, this is possible

Code: Select all

var relatorioNovo = new Stimulsoft.Report.StiReport();
relatorioNovo.loadFile("SimpleList.mrt");

var bandaRodapeNova = relatorioNovo.getComponents().getByName(nomeComponente);

if (bandaRodapeNova != null) {
    /**
     * remove component
     */
    var indiceComponenteOriginal = bandaRodapeOriginal.page.components.indexOf(bandaRodapeOriginal);
    bandaRodapeOriginal.page.components.removeAt(indiceComponenteOriginal);
   
    /**
     * append new component
     */
    bandaRodapeNova.page = relatorioOriginal.pages.getByIndex(0);
    bandaRodapeNova.name = nomeComponente;
    relatorioOriginal.pages.getByIndex(0).components.insert(indiceComponenteOriginal, bandaRodapeNova);
    for (let componente of bandaRodapeNova.components.list) {
        componente.page = relatorioOriginal.pages.getByIndex(0);
        componente.parent = bandaRodapeNova;
        componente.setName(Stimulsoft.Report.StiNameCreation.createName(relatorioOriginal, componente.getName().replace("\\d*", "")));
    }
}
User avatar
rafaelwithoeft
Posts: 70
Joined: Thu Mar 05, 2015 8:26 pm

Re: Override Components

Post by rafaelwithoeft »

That worked partially, some components not correctly rendered (not shown)... like images (url/base64/file)...

Have a workaround for it?
Best Regards
Andrew
Posts: 4108
Joined: Fri Jun 09, 2006 3:58 am

Re: Override Components

Post by Andrew »

Hello,

Thank you for the reply.
Please send us your report to support@stimulsoft.com where we can see what components are not rendered correctly.

Thank you.
User avatar
rafaelwithoeft
Posts: 70
Joined: Thu Mar 05, 2015 8:26 pm

Re: Override Components

Post by rafaelwithoeft »

Hello, sent the codes and reports to email support.

Thank you :)
Andrew
Posts: 4108
Joined: Fri Jun 09, 2006 3:58 am

Re: Override Components

Post by Andrew »

Thank you, we see your question. We will reply you in the ticket system.
Post Reply