Is there any way to print Igrid contents only in a page?
Regards,
Suresh A
Hi,
If i use the above code it clears the headers of the grid itself. Also it just opens a popup window and a blank screen is displayed. But when i see the source of the popup i can see the grid details. Let me know what can i do for that?
Hi Suresh,
Here is the complete code of the handler:
$('#exportButton').click(function (){ var finalTable = $("#grid2").igGrid("headersTable"); $(finalTable).attr('id', 'finalTable'); $('#finalTable').appendTo($('#printgrid2')); var rows = $('#grid2').igGrid('allRows'); rows.each(function(index, element) { var row = $(this).clone(); var completeRow = '<tr>' + $(row).html() + '</tr>'; $(completeRow).appendTo($('#finalTable')); }); var printWin = window.open("", "Printable", " location=no, toolbar=no, titlebar=no, resizable=no, status=no, menubar=no"); printWin.document.open(); printWin.document.write('<table>' + $('#finalTable').html() + '</tr>'); //You can clear the div container here $('#printgrid2').empty(); printWin.print(); });
If you use this approach this binding "onclick="exportButton();"" could be removed as jQuery will attach the handler to the click event
Thanks,
Any updates on this?
Hi Todor,
$('#exportButton').click(function (){
$('<table id="resultTable"></table>').appendTo($('#printgrid2')); var rows = $('#grid2').igGrid('allRows'); rows.each(function(index, element) { var rowData = $(this).clone(); var currentRow = '<tr>' + $(rowData ).html() + '</tr>'; $(currentRow ).appendTo($('#resultTable')); }); var printWin = window.open("", "Printable", " location=no, toolbar=no, titlebar=no, resizable=no, status=no, menubar=no"); printWin.document.open(); printWin.document.write('<table>' + $('#printgrid2').html() + '</tr>'); printWin.print(); printWin.close(); });
<div id="printgrid2"></div><input type="button" value="exportButton" id="exportButton" onclick="exportButton();"/>
I have implemented like above but the thing is i am not getting when do i need to clear the div container. Also in the code you have mentioned .divContainer i have replaced it with printgrid2 let me know is this correct or not. Also if i need to get the headers printed on top then what do i need to do. Also how do i get the borders for ts since we have only table and tr tags in itl PLs correct me if i am wrong.
Have you tried my approach on this? It should work for all the rows in the igGrid.
Thanks