Hello
Please let us know if you need any additional help.
Blazor - add custom Viewer button
-
- Posts: 6244
- Joined: Tue Mar 20, 2018 5:34 am
Re: Blazor - add custom Viewer button
Hi
after update from 2022.4.5 to 2023.1.1 above code is not working,got in console:
works fine if I revert to 2022.4.5
thanks
after update from 2022.4.5 to 2023.1.1 above code is not working,got in console:
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
thanks
-
- Posts: 786
- Joined: Tue Sep 07, 2021 10:11 am
Re: Blazor - add custom Viewer button
Hello,
We need some additional time to investigate the issue, we will let you know about the result.
Thank you.
We need some additional time to investigate the issue, we will let you know about the result.
Thank you.
-
- Posts: 786
- Joined: Tue Sep 07, 2021 10:11 am
Re: Blazor - add custom Viewer button
Hello,
Form version 2023.1.1 we made some changes in Stimulsoft Blazor.
Now you need to use the following code in _Host.cshtml:
and this code at Viewer.razor:
https://github.com/stimulsoft/Samples-B ... %20Toolbar
Thank you.
Form version 2023.1.1 we made some changes in Stimulsoft Blazor.
Now you need to use the following code in _Host.cshtml:
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");
}
}
Thank you.
Re: Blazor - add custom Viewer button
it is working.thanks!
-
- Posts: 786
- Joined: Tue Sep 07, 2021 10:11 am
Re: Blazor - add custom Viewer button
Hello,
You are Welcome!
You are Welcome!