Hi all,
For those who want to be able to print a jqGrid grid, i'd like to offer a nice solution. Even though you only have to specify the main grid id, any sub grids nested within the main grid print out nicely as well. All of this is done on the client side in javascript.
The function adds a print button to the end of the standard jqGrid buttons on the left side of the navigation bar and binds the button to the print function on click. The function uses jQuery and jqGrid methods as well as the third party “printElement” plugin to accomplish the task.
0. download and install Erik Zaadi's “printElement” plugin at: http://projects.erikzaadi.com/…..ntElement/ .
1. create a div container somewhere.
2. create a “print-grid.css” file that contains entries to hide the container and display grid lines on print.
.hide {display:none;}
table {border-collapse:collapse;}
th, td {border:1px solid black; !important}
3. add the “setPrintGrid” function call to the end of your grid definition. The function parameters are (grid_id, pager_id, button_title)
// example jqGrid
$('#tab4-grid').jqGrid({
.
pager: '#tab4-pager',
toppager: true, // comment out if you don't want the the top nav bar.
.
});// setup grid print capability. Add print button to navigation bar and bind to click.
setPrintGrid('tab4-grid','tab4-pager','Customer Grid');
4. add the setPrintGrid function definition to some javascript file with a global namespace.
// setup grid print capability. Add print button to navigation bar and bind to click.
function setPrintGrid(gid,pid,pgTitle){
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top