<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: improved print grid function.</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>NewHistoricForm on improved print grid function.</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p28903</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p28903</guid>
        	        	<description><![CDATA[</p>
<table class=" " style="padding-left: 30px; height: 77px;" border="0" cellspacing="0" cellpadding="0" width="639">
<tbody class=" ">
<tr class=" ">
<td class=" ">
<p>This is exactly what I&#39;m looking for. Only that I can get it to work. I keep getting an error:&#160;</p>
<div class="errorTitle focusRow subLogRow ">TypeError: $.browser is undefined</div>
<table class=" " border="0" cellspacing="0" cellpadding="0">
<tbody class=" ">
<tr class=" ">
<td class=" ">[Image Can Not Be Found]</td>
<td class=" "><a class="errorSource a11yFocus " target="_blank"></p>
<pre class="errorSourceCode " title="if ($.browser.opera &#124;&#124; (/chrome/.test(navigator.userAgent.toLowerCase())))">if ($.browser.opera &#124;&#124; (/chrome/.test(navigator.userAgent.toLowerCase())))<br /></pre>
</p>
<p></a></td>
</tr>
</tbody>
</table>
<p>I think that I didn&#39;t correctly insert the setPrintGrid function correctly as I just created printGrid. js file and inserted there. But i have no idea what a "global namespace" is. Here is my code:</p>
<p>&#160;&#160;&#160;&#160; &#60;script src="js/printgrid.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#60;script src="js/jquery-1.9.0.min.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script src="js/i18n/grid.locale-en.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script src="js/jquery.jqGrid.min.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#160;&#60;script src="js/jquery-ui-1.10.3.custom.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#160;&#160; &#60;script src="js/jquery.printelement.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script type="text/javascript"&#62;&#160;&#160; &#160;&#160;&#160; &#160; </p>
<p>$(function(){ <br />&#160; $("#list").jqGrid({<br />&#160;&#160;&#160; url:&#39;request.php&#39;,<br />&#160;&#160; &#160;editurl: "jqGridCrud.php",<br />&#160;&#160;&#160; datatype: &#39;xml&#39;,<br />&#160;&#160;&#160; mtype: &#39;GET&#39;,<br />&#160;&#160; &#160;multiselect:true,<br />&#160;&#160; &#160;multiboxonly:true,<br />&#160;&#160; &#160;height: 530,<br />&#160;&#160; &#160;width: 850,<br />&#160;&#160; &#160;<br />&#160;&#160;&#160; colNames:[&#39;id&#39;,&#39;Project&#39;, &#39;Assigned To&#39;,&#39;Assign Date&#39;,&#39;Check Date&#39;,&#39;Due Date&#39;,&#39;Attachments&#39;],<br />&#160;&#160;&#160; colModel :[ <br />&#160;&#160;&#160;&#160;&#160; {name:&#39;id&#39;, index:&#39;id&#39;, width:25}, <br />&#160;&#160;&#160;&#160;&#160; {name:&#39;name&#39;, index:&#39;name&#39;, width:250, align:&#39;left&#39;,editable:true, editoptions:{<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; size:60} }, <br />&#160;&#160;&#160;&#160;&#160; {name:&#39;id_continent&#39;, index:&#39;id_continent&#39;, width:55, align:&#39;right&#39;,editable:true,edittype:&#39;select&#39;, <br />&#160;&#160; &#160;&#160; editoptions:{value: "Henry:Henry; Ramon:Ramon; Paul:Paul" },mtype:&#39;POST&#39;&#160; }, <br />&#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160; {name:&#39;lastvisit&#39;, index:&#39;lastvisit&#39;, width:70, align:&#39;right&#39;,formatter: &#39;date&#39;,srcformat:&#39;mm-dd-yyyy&#39;,newformat: &#39;mm-dd-yyyy&#39;,editable:true, edittype: &#39;text&#39;,mtype:&#39;POST&#39; ,editoptions:{size:10, dataInit:function(elem){$(elem).datepicker({dateFormat:&#39;mm-dd-yyyy&#39;});}}} ,<br />&#160;&#160; &#160; &#160;<br />&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160; {name:&#39;cdate&#39;, index:&#39;cdate&#39;, width:70, align:&#39;right&#39;,formatter: &#39;date&#39;,srcformat:&#39;mm-dd-yyyy&#39;,newformat: &#39;mm-dd-yyyy&#39;, edittype: &#39;text&#39;,editable:true ,mtype:&#39;POST&#39; ,editoptions:{size:10, dataInit:function(elem){$(elem).datepicker({dateFormat:&#39;mm-dd-yyyy&#39;});}}} ,<br />&#160;&#160; &#160; <br />&#160;&#160; &#160;&#160; {name:&#39;ddate&#39;, index:&#39;ddate&#39;, width:70, align:&#39;right&#39;,formatter: &#39;date&#39;,srcformat:&#39;mm-dd-yyyy&#39;,newformat: &#39;mm-dd-yyyy&#39;,editable:true, edittype: &#39;text&#39;,editoptions:{size:10, dataInit:function(elem){$(elem).datepicker({dateFormat:&#39;mm-dd-yyyy&#39;});}}} ,<br />&#160;&#160; &#160; &#160;<br />&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160; {name:&#39;email&#39;, index:&#39;email&#39;, width:70,align:&#39;center&#39;,sortable:false,mtype:&#39;POST&#39;, formatter: &#39;link&#39; } <br />&#160;&#160;&#160; ],<br />&#160;&#160;&#160; pager: &#39;#pager&#39;,<br />&#160;&#160; &#160;<br />&#160;&#160;&#160; rowNum:20,<br />&#160;&#160;&#160; rowList:[20,40,80],<br />&#160;&#160;&#160; sortname: &#39;id&#39;,<br />&#160;&#160;&#160; sortorder: &#39;desc&#39;,<br />&#160;&#160;&#160; viewrecords: true,<br />&#160;&#160;&#160; gridview: true,<br />&#160;&#160;&#160; caption: &#39;Pending Assignments&#39;,<br />&#160;&#160; &#160;<br />&#160;ondblClickRow: function(rowid) {<br />&#160;&#160; &#160;<br />&#160;&#160; &#160;$(this).jqGrid(&#39;editGridRow&#39;, rowid,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {width:450,Height:400,recreateForm:true,closeAfterEdit:true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; closeOnEscape:true,reloadAfterSubmit:false, modal:true,mtype:&#39;post&#39;});}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160; <br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160; <br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });<br />&#160;&#160; &#160; </p>
<p>&#160;$("#list").jqGrid("navGrid", "#pager", { add: false, search: false });<br />&#160;<br />&#160;&#160; &#160;</p>
<p>&#160;&#160;&#160; // setup grid print capability. Add print button to navigation bar and bind to click.<br />&#160;&#160;&#160; setPrintGrid(&#39;list&#39;,&#39;pager&#39;,&#39;Print&#39;);</p>
<p>&#160;&#160;&#160; });<br />&#60;/script&#62;</p>
</p>
</td>
</tr>
</tbody>
</table>
]]></description>
        	        	<pubDate>Tue, 28 May 2013 23:10:00 +0300</pubDate>
        </item>
        <item>
        	<title>bogus on improved print grid function.</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p28633</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p28633</guid>
        	        	<description><![CDATA[<p>thanx for good work!</p>
<p>I&#39;ve tried in Firefox, Chrome and IE. There are some problems.</p>
<p>1) With big textarea fields, Firefox print all, IE &#8211; the same. Chrome loses the rightmost part.</p>
<p>2) If width of columns is not set and field content is rather short &#8211; all OK. But, if width is set, and table body has long text fields &#8211; then header columns width is different from body. I suppose the clue is something like this:<br />- grid consists of several tables &#8211; e.g. one for header, one for body.</p>
<p>- long text fields adjust width accordinng to text size</p>
<p>So, may be some kind of solution is to copy header cells with width attributes to the body table and remove the header table. This way &#8211; the header and the body columns will be the same width.</p>
<p>I put this:<br />var t1=$(&#39;#prt-container thead&#39;);&#160;</p>
<p>$(&#39;#prt-container tbody&#39;).before(t1.clone());</p>
<p>&#160;t1.remove();&#160;&#160;</p>
</p>
<p>And it fixes my table.</p>
</p>
<p>I don&#39;t know, if is possible with subgrids&#8230;&#160;</p>
]]></description>
        	        	<pubDate>Thu, 11 Apr 2013 00:36:26 +0300</pubDate>
        </item>
        <item>
        	<title>nelsonm on improved print grid function.</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p27769</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p27769</guid>
        	        	<description><![CDATA[<p>yes, i noticed the issue as well.&#160; Unfortunetly, I don&#39;t have time to look into it at the moment.</p>
<p>I guess that it may have something to to with css incompatability.&#160; try tweaking the css file.</p>
</p>
<p>good luck.</p>
]]></description>
        	        	<pubDate>Wed, 21 Nov 2012 23:08:15 +0200</pubDate>
        </item>
        <item>
        	<title>ginak1004 on improved print grid function.</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p27768</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p27768</guid>
        	        	<description><![CDATA[<p>I tried this and it works all fine except Chrome.</p>
<p>It works fine at IE and firefox, but when i use Chorme, i can&#39;t see any grid lines.</p>
<p>Could you help me?</p>
</p>
<p>Thanks</p>
]]></description>
        	        	<pubDate>Wed, 21 Nov 2012 22:05:13 +0200</pubDate>
        </item>
        <item>
        	<title>nelsonm on improved print grid function.</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p27381</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p27381</guid>
        	        	<description><![CDATA[<p>Sorry, i made a little error...</p>
<p>Please name the css file <strong>"print-container.css" </strong>instead of "print-grid.css".&#160; The function will still work but you won&#39;t get any grid lines if you don&#39;t name the css file <strong>"print-container.css"</strong>.</p>
]]></description>
        	        	<pubDate>Tue, 25 Sep 2012 01:36:26 +0300</pubDate>
        </item>
        <item>
        	<title>nelsonm on improved print grid function.</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p27379</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p27379</guid>
        	        	<description><![CDATA[<p>Here is my jqgrid screen.</p>
<p><a href="http://www.nados.com/public/jqgrid-screen.png"><img src="http://www.nados.com/public/jqgrid-screen.png" width="100"  class="sfimageleft spUserImage" alt="" /><img src="http://www.trirand.com/blog/wp-content/sp-resources/forum-themes/default/images/sp_Mouse.png" class="sfimageleft sfmouseleft" alt="Image Enlarger" /></a></p>
</p>
<p>Here is an image of a work order grid printout with subgrids.</p>
<p><a href="http://www.nados.com/public/jqgrid-print.png"><img src="http://www.nados.com/public/jqgrid-print.png" width="100"  class="sfimageleft spUserImage" alt="printout of grid" /><img src="http://www.trirand.com/blog/wp-content/sp-resources/forum-themes/default/images/sp_Mouse.png" class="sfimageleft sfmouseleft" alt="Image Enlarger" /></a></p>
]]></description>
        	        	<pubDate>Tue, 25 Sep 2012 01:26:30 +0300</pubDate>
        </item>
        <item>
        	<title>nelsonm on improved print grid function.</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p27378</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/improved-print-grid-function#p27378</guid>
        	        	<description><![CDATA[<p>Hi all,</p>
<p>I improved the "setPrintGrid" function a bit.&#160; You no longer have to manually define the ".hide" css class or the print  container div.&#160; The "setPrintGrid" function now does that for you.&#160; All  you have to do is create the "print-grid.css" file, add the function code to a javascript file and place the function call after any and all grid definitions.</p>
<p>For those who want to be able to print a jqGrid grid, i&#39;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.</p>
<p>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.</p>
<p>Follow the steps below to set it up.</p>
<p>1. download and install Erik Zaadi&#39;s "printElement" plugin at: <a rel="nofollow" href="http://projects.erikzaadi.com/" target="_blank">http://projects.erikzaadi.com/</a>&#8230;..038;hellip;..ntElement/ .</p>
</p>
<p>2. create a "print-grid.css" file that contains entries to display grid lines on print.&#160; the "print-grid.css" file should NOT be defined on the index or any  other page.&#160; It should just exist in the css folder of the site and be  called from the "printElement" plugin.</p>
<blockquote>
<p>#prt-container table {<br />&#160;&#160; &#160;border-collapse:collapse;<br />}</p>
<p>#prt-container th,<br />#prt-container td {<br />&#160;&#160; &#160;border:1px solid black;<br />}</p>
</blockquote>
<p>3. add the "setPrintGrid" function call to the end of your grid definition but within the "document ready" function.  The function parameters are (grid_id, pager_id, button_title)</p>
<blockquote>
<p>$(function() {</p>
<p>// example jqGrid<br />$(&#39;#tab4-grid&#39;).jqGrid({<br />.<br />pager: &#39;#tab4-pager&#39;,<br />toppager: true, // comment out if you don&#39;t want the the top nav bar.<br />.<br />});</p>
<p>// setup grid print capability. Add print button to navigation bar and bind to click.<br /><strong>setPrintGrid(&#39;tab4-grid&#39;,&#39;tab4-pager&#39;,&#39;Customer Grid&#39;);</strong></p>
<p>});</p>
</blockquote>
<p>4. add the "setPrintGrid" function definition to some javascript file with a global namespace.</p>
<blockquote>
<p>&#160;&#160;&#160; // setup grid print capability.&#160; Add print button to navigation bar and bind to click.<br />&#160;&#160; &#160;function setPrintGrid(gid,pid,pgTitle){<br />&#160;&#160; &#160;&#160;&#160; &#160;// print button title.<br />&#160;&#160; &#160;&#160;&#160; &#160;var btnTitle = &#39;Print Grid&#39;;</p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;// setup print button in the grid top navigation bar.<br />&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#&#39;+gid).jqGrid(&#39;navSeparatorAdd&#39;,&#39;#&#39;+gid+&#39;_toppager_left&#39;, {sepclass :&#39;ui-separator&#39;});<br />&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#&#39;+gid).jqGrid(&#39;navButtonAdd&#39;,&#39;#&#39;+gid+&#39;_toppager_left&#39;, {caption: &#39;&#39;, title: btnTitle, position: &#39;last&#39;, buttonicon: &#39;ui-icon-print&#39;, onClickButton: function() {&#160;&#160; &#160;PrintGrid();&#160;&#160; &#160;} });<br />&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;// setup print button in the grid bottom navigation bar.<br />&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#&#39;+gid).jqGrid(&#39;navSeparatorAdd&#39;,&#39;#&#39;+pid, {sepclass : "ui-separator"});<br />&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#&#39;+gid).jqGrid(&#39;navButtonAdd&#39;,&#39;#&#39;+pid, {caption: &#39;&#39;, title: btnTitle, position: &#39;last&#39;, buttonicon: &#39;ui-icon-print&#39;, onClickButton: function() { PrintGrid();&#160;&#160; &#160;} });<br />&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;function PrintGrid(){<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;// attach print container style and div to DOM.<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;head&#39;).append(&#39;&#60;style type="text/css"&#62;.prt-hide {display:none;}&#60;/style&#62;&#39;);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;body&#39;).append(&#39;&#60;div id="prt-container" class="prt-hide"&#62;&#60;/div&#62;&#39;);</p>
<p>&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;// copy and append grid view to print div container.<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#gview_&#39;+gid).clone().appendTo(&#39;#prt-container&#39;).css({&#39;page-break-after&#39;:&#39;auto&#39;});</p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;// remove navigation divs.<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#prt-container div&#39;).remove(&#39;.ui-jqgrid-toppager,.ui-jqgrid-titlebar,.ui-jqgrid-pager&#39;);</p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;// print the contents of the print container.&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#prt-container&#39;).printElement({pageTitle:pgTitle, overrideElementCSS:[{href:&#39;css/print-container.css&#39;,media:&#39;print&#39;}]});</p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;// remove print container style and div from DOM after printing is done.<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;head style&#39;).remove();<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;body #prt-container&#39;).remove();<br />&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;}</p>
</blockquote>
<p>I hope this helps.</p>
]]></description>
        	        	<pubDate>Tue, 25 Sep 2012 01:01:17 +0300</pubDate>
        </item>
</channel>
</rss>