Is there any way to print Igrid contents only in a page?
Regards,
Suresh A
Hi Suresh,
Can you specify what do you mean with igGrid Contents only? Do you want to print all the rows loaded on the page?
Thanks,
Yes i want to print all the rows in the grid. I have not enabled paging in my grid.
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
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?
Also FYI i am using row template to build the grid.
Hi Todor,
Any clue for the issue i am facing? Did you tried it?
Hello Suresh,
Thank you for your update.
I created a support ticket on your behalf
CAS-83130-2VY8MP
You can upload your isolated sample reproducing the issue there.
Hope hearing from you.
Thank you for solving my problem with paginated tables.If you want to have styles for the table I want to print, as it should?Thanks in advance.
Best Regards.
I have a solution which assumes that the whole data is available in the browser i.e. grid is not configured to use remote paging.
The idea is to get the data form the grid data source object and then use it to generate new table with the whole data in it. The original igGrid is not touched. CSS media rules are used to hide the original igGrid when in @media print and show the generated one and vice versa in @media screen mode. If you use a custom button for printing you can delay the generation of the print table until the button is clicked. If you want user to be able to use the browser "Print" button then you should generate the print table after you create the igGrid.
The downside of this method is that you should keep an extra TABLE element in the DOM. If there are too many records in the data source then this may degrade the performance of the page.
Attached you can find a reference implementation of the described method. I used custom button for printing in order to show you a workaround for Internet Explorer. Internet Explorer doesn't like generating the print table on demand before printing. That's why I use conditional comments for IE in order to workaround the problem.
P.S.: It doesn't make sense to use remote paging in case that you want to print the whole data. That's why I didn't cover that scenario.
Hope this helps,
Martin Pavlov
Infragistics, Inc.
I have a question similar to this post resolved.
How could we get all the data in the table if the grid is paged? If the grid is paged, we can only access the data of the displayed page. Will print only the current page data. Thanks in advance.
Best Regards
I have uploaded a sample code and the issue which i am facing. Kindly have a look at it and provide me a solution for the same.
Thank you for your great interest in our jQuery grid.
I asked you for an isolated sample in purpose.
I was not able to reproduce the issue using the code snippet provided by Todor
http://community.infragistics.com/forums/t/64705.aspx?PageIndex=2#330000
and the instructions from Martin
http://community.infragistics.com/forums/t/64705.aspx?PageIndex=2#329378
I am attaching the sample I used, trying to replicate the behavior.
Hope hearing from you