1

I open my JQplot on a modal Div window, which has a print button.

I want the print button to only print the graph.

Or possibly open a new window with a graph in it.

What do you think is the best route and how would that solution work?

WhiteKnight
  • 4,938
  • 5
  • 37
  • 41
nipiv
  • 773
  • 1
  • 8
  • 21

1 Answers1

1

You could call something like this thats inside of an onclick

//if the print button is in parent window   
$("#iframe")[0].contentWindow.window.PrintFrame();

//runs in child frame
function PrintFrame() 
{
     //hide everything you don't want to see besides the graph
     window.focus();
     window.print();
}

I would not open a new window.

Just create an anchor tag with an onClick event. Inside the event hide everything you don't want and then fire window.print(). Another way would be to create a print style sheet and hide everything you don't want to show up in the print style sheet.

How does this print stylesheet work?

Community
  • 1
  • 1
bigamil
  • 657
  • 4
  • 12
  • Thanks a lot for the reply Amil. Well i am kinda doing the same BUT The problem is that my graph gets generated on the fly through javascript. So it doesnt get generated when i pass the content into a new window. :( – nipiv Feb 28 '12 at 09:31
  • In that case cant you just use a css print style sheet? Or you could remove all the dom items besides the graph and call windows.print() on a click event like I described above. Does that answer your question? – bigamil Feb 28 '12 at 14:43
  • kinda.. but not entirely... as i have to show the user wats gona get printed. thats y we have this new window in which we show wat and how is ur print gona look like.. well i had to call the graph function again in the new window so that it cud print it... and it got resolved :) – nipiv Feb 29 '12 at 10:36
  • Alright gotcha. So did my answer help you solve your problem? If so please mark it as the answer! Thanks man – bigamil Feb 29 '12 at 14:54