views:

25

answers:

2

I want to send table values to printer.That table contails more than 50 records.so there is scrollbar or pagination on that table.Below the printer there print button, if click the button those all values should go to printer.

function print(){

window.print();
window.opener.document.location = window.opener.document.location.href;
window.close();

  }

I used to code for print value.but it shows only the page, not in all table values .I ma using jsp,javascript.

I am looking for directdownload without css and open popup window, i need to do this work.

Any idea????

A: 

I'm assuming that you want to print the entire table of values. In that case, I would have a separate method (action) or different parameters/values to return the entire table unpaginated -- perhaps on it's own without the rest of the surrounding page if all you want printed is the table. Use this method (action/parameters) as the url for a new window that you pop up. The action should also return some javascript on the page that, once the load event occurs, prints the page.

function print()
{
    window.open( '/foo?page=all&print=true', '_blank', '', false );
}

Then on the new page:

$(function()) {
    window.print();
});
tvanfosson
A: 

If you always want to print the whole table but nothing arround I would recommend to use a CSS print stylesheet. In this CSS file you can hide all elements except of the table. The user can than also use the print function of his browser (or CTRL + P). If you just want to print only the table when a user clicks the button, just add that CSS file on the click, fire the window.print() function and afterwards remove the CSS.

Kau-Boy