Dashboards & Visualizations

Why does the print dialog launches unexpectedly after printing?

davefarmersplun
New Member

I am a newbie to Splunk, and am doing maintenance on some legacy code and I noticed that whenever I refresh the dashboard after having printed, the print dialog will re-launch unexpectedly.

The code for printing hooks the dashboard click event for the Splunk print icon:

    $("#dashboard").on("click", "#print", function(e){

Then the click-event code creates a window, populates it with the contents that will be printed, and then launches the print dialog:

                    var win = window.open("", "_blank");
                    win.document.write($("head").html());

                    //create css element
                    var css = document.createElement("STYLE");
                    css.appendChild(document.createTextNode('th{background-color:#e6e6e6;} tr:nth-child(odd){background-color:#d5e2e9;} td{border: 1px solid #e8eef4;padding: 5px;}'));
                    win.document.write(css.outerHTML);

                    //create table and 
                    win.document.write(str.outerHTML);
                    win.document.close();
                    win.print();

So the question is "why does the print dialog get relaunched?. Is there an issue with tokens? Note that the click event code is not re-entered for this scenario. The print dialog (which becomes a new tab) is recreated, but not by the code.

I hope you can help.

Tags (3)
0 Karma

davefarmersplun
New Member

The version of Splunk used is 6.5.2.

Additionally, the dialog is re-displayed without entering the code that launches it. In other words, the dashboard "print" click is not fired.

0 Karma

niketn
Legend

@davefarmersplunk, which version of Splunk are you using? Under the Dashboard Export option, you should also have a built in option to Print the dashboard without having to depend on custom JavaScript.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...