AnsweredAssumed Answered

Basic printing for a datagrid

Question asked by schlot on Jan 4, 2013
Latest reply on Jan 7, 2013 by schlot
What is the easiest way to print the contents of a datagrid?  I have a grid that is populated with the results of a query or find.  My frame is defined as
    <div id="bottomPane" data-dojo-type="dijit.layout.ContentPane" region="bottom" style="width:auto, position:absolute; top:auto">               <div dojoType="dojox.layout.Dock" id="dock" widgetid="dock"></div>            <h3 id="gridTitle">Providers in this area: </h3>            Click Provider Map to see these locations.          <button id="btnPrint" dojotype="dijit.form.Button" onClick="printIt(document.getElementById('resultsGrid').innerHTML); return false;" title="Print List" value="Print List">Print List</button>            <table data-dojo-type="dojox.grid.DataGrid" id="resultsGrid" selectionmode="none" >           <thead>              <tr>               <th field="PIN" formatter="makeZoomButton" width="35px" title="First, open map,click on ID to see location.">                </th>                <th field="FACILITY" width="400px">Provider</th>                <th field="ADDRESS" width="320px">Address</th>                 <th field="CITY" width="190px">City</th>                  <th field="PHONE" width="150px">Phone</th>              </tr>            </thead>          </table>           </div> 

My print button calls a function that creates a simple HTML for printing:
   function printIt(printThis) { var win =; self.focus();; win.document.write('<'+'html'+'><'+'head'+'><'+'style'+'>'); win.document.write('body, td { font-family: Verdana; font-size: 12pt;}'); win.document.write('<'+'/'+'style'+'><'+'/'+'head'+'><'+'body'+'>'); win.document.write(printThis); win.document.write('<'+'/'+'body'+'><'+'/'+'html'+'>'); win.document.close(); win.print(); win.close(); }

This does create something printable, but the rows are at the very top of the page and the headers are sandwiched between the 1st and 2nd row.  I'm thinking it might be as simple as adding some additional styling to this print function?  Also there are two small square at the bottom that are maybe tiny cells?  They look like checkboxes.  I thought maybe it was the zoom icon I have in the first column that will add an infoWindow, but I took that out and it didn't make a difference. 

I did find that the enhanced grid maybe had some printing capabilities, but I don't want to pull apart my entire code, which is done except for this printing.