Page 1 of 1

Override Components

Posted: Mon Oct 05, 2015 12:01 pm
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

Re: Override Components

Posted: Mon Oct 05, 2015 1:29 pm
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*", "")));
    }
}

Re: Override Components

Posted: Mon Oct 05, 2015 8:34 pm
by rafaelwithoeft
That worked partially, some components not correctly rendered (not shown)... like images (url/base64/file)...

Have a workaround for it?
Best Regards

Re: Override Components

Posted: Tue Oct 06, 2015 5:44 am
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.

Re: Override Components

Posted: Tue Oct 06, 2015 11:55 am
by rafaelwithoeft
Hello, sent the codes and reports to email support.

Thank you :)

Re: Override Components

Posted: Tue Oct 06, 2015 12:51 pm
by Andrew
Thank you, we see your question. We will reply you in the ticket system.