Re: Blazor - add custom Viewer button
Posted: Mon Apr 26, 2021 8:25 pm
Hello
Please let us know if you need any additional help.
Please let us know if you need any additional help.
Reporting tool and data analytics tools for creating reports and dashboards in ASP.NET, ASP.NET MVC, .NET Core, Blazor, Angular, PHP, Python, WPF, JavaScript, and Java applications.
https://forum.stimulsoft.com/
Code: Select all
Unhandled Exception:
Microsoft.JSInterop.JSException: this.WebViewer1.SmallButton is not a function
blazor.webassembly.js:1 TypeError: this.WebViewer1.SmallButton is not a function
Code: Select all
<script>
var createButton = function () {
// 'jsWebViewer1' is a 'js' prefix plus the component ID
var customButton = this.jsWebViewer1.SmallButton("customButton", "Custom Button", "emptyImage");
customButton.image.src = "icon.png";
customButton.action = function () {
alert("Custom Button Event");
}
var toolbarTable = this.jsWebViewer1.controls.toolbar.firstChild.firstChild;
var buttonsTable = toolbarTable.rows[0].firstChild.firstChild;
var customButtonCell = buttonsTable.rows[0].insertCell(0);
customButtonCell.appendChild(customButton);
}
</script>
Code: Select all
<StiBlazorViewer ID="WebViewer1" Report="@report" OnViewerAfterRender="@OnAfterRenderViewer" />
@code
{
//Report object to use in viewer
private StiReport report;
protected override void OnInitialized()
{
base.OnInitialized();
//Init base font
StiFontCollection.AddFontFile($"Fonts/OpenSans-Regular.ttf");
//Create empty report object
report = new StiReport();
//Load report template
report.Load($"Reports/TwoSimpleLists.mrt");
}
private void OnAfterRenderViewer()
{
JSRuntime.InvokeVoidAsync("createButton");
}
}
Code: Select all
Unhandled exception rendering component: Object of type 'Stimulsoft.Report.Blazor.StiBlazorViewer' does not have a property matching the name 'OnAfterRenderEvent'.
mrapi wrote: ↑Wed Apr 21, 2021 11:00 am Hi
tried the code but gotI have the latest version(2021.2.3)Code: Select all
Unhandled exception rendering component: Object of type 'Stimulsoft.Report.Blazor.StiBlazorViewer' does not have a property matching the name 'OnAfterRenderEvent'.
thanks