Add Custom Button to Designer

Stimulsoft Reports.JS discussion
Post Reply
du8die
Posts: 4
Joined: Wed May 13, 2020 1:17 am

Add Custom Button to Designer

Post by du8die »

Hi,

I'm looking to add a custom button to the designer toolbar. Vanilla JS. Has anyone gotten this to work?

Thanks!
Andrew
Posts: 4105
Joined: Fri Jun 09, 2006 3:58 am

Re: Add Custom Button to Designer

Post by Andrew »

Hello,

Thank you for the question.

Please try this code

<body>
<div onclick="aaa()">Load Report</div>
<form id="form1" runat="server">
<div>
<cc3:StiWebDesigner runat="server" ID="StiWebDesigner1" />
</div>
</form>
<script>
//where jsStiWebDesigner1 - "js" + designer ID
var toolBarRow = jsStiWebDesigner1.options.toolBar.firstChild.tr[0];


//Add images for custom buttons to designer images collection
jsStiWebDesigner1.options.images["ImageForCustomButton1"] = "https://www.stimulsoft.com/favicon.ico"; //For example


var customButton = jsStiWebDesigner1.StatusPanelButton("customButton1", null, "ImageForCustomButton1", null, null, 30, 30);
customButton.image.style.width = customButton.image.style.height = "16px";
var buttonCell = document.createElement("td");
buttonCell.className = "stiDesignerToolButtonCell";
buttonCell.appendChild(customButton);


toolBarRow.insertBefore(buttonCell, toolBarRow.childNodes[3]);


customButton.action = function () {
alert("Button clicked!");
}
</script>
</body>
du8die
Posts: 4
Joined: Wed May 13, 2020 1:17 am

Re: Add Custom Button to Designer

Post by du8die »

Thank you.

However, I am not using the .net library. I am using the vanilla JS library.

jsStiWebDesigner1.options.toolBar is undefined.

Thanks for the help!
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Add Custom Button to Designer

Post by HighAley »

Hello.

The JS part of the Designer is the same.
Please, try jsStiDesigner.options.toolBar instead.
The Designer object should be created.

Thank you.
du8die
Posts: 4
Joined: Wed May 13, 2020 1:17 am

Re: Add Custom Button to Designer

Post by du8die »

There it is!

Thanks!
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Add Custom Button to Designer

Post by HighAley »

Hello,

We are always glad to help you.
Let us know if you need any additional help.

Thank you.
Post Reply