Posted 3 May 2023, 11:31 pm EST
Hello,
I’m having some problems when I build in a dynamic environment.
I make some changes accessing the querySelector and on my local machine it works but not on the environment.
I use angular 8 with version 16 of spread.
An example:
designer: Designer.Spread.Sheets.Designer.Designer;
workbook: GC.Spread.Sheets.Workbook = null;
...
ngOnInit() {
const divSPread = document.getElementById('designer-container') as HTMLDivElement;
this.designer = new Designer.Spread.Sheets.Designer.Designer(divSPread, this.spreadDesignerConfig);
this.workbook = this.designer.getWorkbook() as GC.Spread.Sheets.Workbook;
this.initDesigner();
}
initDesigner() {
const colors = ['#fb4455', '#ffce55', '#45dd98', '#1e194f', '#afaafe', '#333c4e', '#808389', '#b8bcc5', '#e1e4ea', '#f1f5fb'];
document.querySelector('.ribbon-button-item[data-command="ribbon.backColor"]').addEventListener('click', (_) => {
this.mudarAsCoresPadroes(colors);
});
...
}
private mudarAsCoresPadroes(colors) {
const color = this.translateService.instant('MEMORIA_CALCULO.STANDARD_COLORS_TITLE');
const colorElements = document.querySelectorAll(`[group-name="${color}"]`);
for (let index = 0; index < 10; index++) {
const element: any = colorElements[index];
element.style.backgroundColor = colors[index];
element.setAttribute('color', colors[index]);
}
}
In the code snippet I am making a change in the default colors of the color palette but it doesn’t work in the dynamic environment.