Forum
04:32
Moderators
30/10/2007
Hello,
I think that this is a "little" difficult. Printing from html is a not trivial task.
You can construct you own printing function. You have all the needed
data and can construct what you want.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
16:35
19/12/2008
Hi,
I needed this functionality too. What I did is that I added a "print" button in the toolbar.
Then with jQuery, I clone jqGrid table in a new window (a bit dirty to find the table, but It works, even if you have multiple tables on your page) :
// Parent container of the "list" DIV (In my case, I have a DIV includind all elements of a jqGrid table)
var idMasterDiv = $('#'+gridName).parent().parent().attr('id');
// Find jqGrid table to print
$('div[id^="jqgh"]').each ( function() {
var idParentDiv = $(this).parent().parent().parent().parent().parent().parent().attr('id');
if (idParentDiv == idMasterDiv && objetEntete==false) {
objetEntete = $(this).parent().parent().parent(); // THEAD of the header row (title of the fields)
}
});
// Create a hidden div which will contain the data to be printed
$('<div>').attr('id', 'printDiv').css('display', 'none').appendTo('body');
// Add css to custom the printed document
$('<link rel="stylesheet" href="css/general.css" media="all" type="text/css"/>').appendTo('#printDiv');
$('<link rel="stylesheet" href="css/print.css" media="all" type="text/css"/>').appendTo('#printDiv');
$('<table>').attr('id', 't_printDiv').appendTo('#printDiv');
// Clone jqGrid table header
$('<caption>'+titrePage+'</caption>').appendTo('#t_printDiv');
objetEntete.clone().appendTo('#t_printDiv');
// Clone jqGrid data
$('#'+gridName+' tbody:first').clone().appendTo('#t_printDiv');
$('</table>').appendTo('#printDiv');
// Open a new window
var WindowObject = window.open('', "TrackHistoryData",
"width=900,height=400,top=200,left=150,toolbars=yes,scrollbars=yes,status=no,resizable=no");
// Send the DIV to be printed in the window
WindowObject.document.writeln($('#printDiv').attr('innerHTML'));
// Clean the current document
$('#printDiv').remove();
WindowObject.document.close();
// Print the table
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}
If anybody have a more simple way of finding the corect <thead> & <tbody> elements to print, I'll be glad !
Most Users Ever Online: 715
Currently Online:
48 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66