Using Angular 6,I've added a custom button to viewer but I'm not able to call component method from it,I got
core.js:1598 ERROR TypeError: this.myMethod is not a function
the code used :
Code: Select all
ngOnInit() {
var report = new Stimulsoft.Report.StiReport();
report.loadFile("reports/Report.mdc");
this.viewer.report = report;
this.viewer.renderHtml("viewer");
const userButton = this.viewer.jsObject.SmallButton('userButton', 'MyButton', 'emptyImage');
userButton.action = function () {
alert('ok');
this.myMethod();
};
const toolbarTable = this.viewer.jsObject.controls.toolbar.firstChild.firstChild;
const buttonsTable = toolbarTable.rows[0].lastChild.lastChild;
const userButtonCell = buttonsTable.rows[0].insertCell(0);
userButtonCell.className = 'stiJsViewerClearAllStyles';
userButtonCell.appendChild(userButton);
}
myMethod(){
alert('call myMethod') ;
}
thanks