Hello, I have a button which when clicks sends exam_id to server. The method queries results of all the students who has appeared in this exam (No. of student > 30). I want to now print this data at client side. I am confused how do I achieve this? I dont want to display this data at client side... instead, I just want to show a progress bar that printing in progress and once I get all the data from server, I need to print it. Any pointers to get started on this? -- Thanks, Jaikishan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This is not possible. You don''t tell the client to "print" something, you may write javascript code to print the current page, but you can not print something without sending it to the client (and asking the browser to print it). What you may do is try to hide the content in the page until a "print" button is clicked, but the data has to be visible somewhere on the page to be printed. The javascript code to tell the browser to print is "window.print()". - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Sat, Dec 6, 2008 at 7:11 PM, Jaikishan Jalan <jai.ism-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I have a button which when clicks sends exam_id to server. The method > queries results of all the students who has appeared in this exam (No. of > student > 30). I want to now print this data at client side. I am confused > how do I achieve this? I dont want to display this data at client side... > instead, I just want to show a progress bar that printing in progress and > once I get all the data from server, I need to print it. > > Any pointers to get started on this? > > -- > Thanks, > Jaikishan > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe what you could do is to generate the data to be printed in a document that the user could download, then you send a page with a button to download it as a file that then they could print, but I guess this defeats the purpose of ''automating'' the printing of the data. Pepe On Dec 6, 5:25 pm, "Maurício Linhares" <mauricio.linha...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This is not possible. > > You don''t tell the client to "print" something, you may write > javascript code to print the current page, but you can not print > something without sending it to the client (and asking the browser to > print it). > > What you may do is try to hide the content in the page until a "print" > button is clicked, but the data has to be visible somewhere on the > page to be printed. > > The javascript code to tell the browser to print is "window.print()". > > - > Maurício Linhareshttp://alinhavado.wordpress.com/(pt-br) |http://blog.codevader.com/(en) > > On Sat, Dec 6, 2008 at 7:11 PM, Jaikishan Jalan <jai....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello, > > > I have a button which when clicks sends exam_id to server. The method > > queries results of all the students who has appeared in this exam (No. of > > student > 30). I want to now print this data at client side. I am confused > > how do I achieve this? I dont want to display this data at client side... > > instead, I just want to show a progress bar that printing in progress and > > once I get all the data from server, I need to print it. > > > Any pointers to get started on this? > > > -- > > Thanks, > > Jaikishan--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Here is what I did - something similar to what Mauricio said. I made a link_to_remote and when user clicks on it, it updates a div (display:none) with the data from the server. Using :complete attribute of link_to_remote, I call a javascript function which then creates a window taking data from the hidden div and then print the window via window.print() command. It is working fine and giving me exactly what I wanted. Thanks for your help. On Sun, Dec 7, 2008 at 8:24 PM, pepe <Pepe-gUAqH5+0sKL6V6G2DxALlg@public.gmane.org> wrote:> > Maybe what you could do is to generate the data to be printed in a > document that the user could download, then you send a page with a > button to download it as a file that then they could print, but I > guess this defeats the purpose of ''automating'' the printing of the > data. > > Pepe > > On Dec 6, 5:25 pm, "Maurício Linhares" <mauricio.linha...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > This is not possible. > > > > You don''t tell the client to "print" something, you may write > > javascript code to print the current page, but you can not print > > something without sending it to the client (and asking the browser to > > print it). > > > > What you may do is try to hide the content in the page until a "print" > > button is clicked, but the data has to be visible somewhere on the > > page to be printed. > > > > The javascript code to tell the browser to print is "window.print()". > > > > - > > Maurício Linhareshttp://alinhavado.wordpress.com/(pt-br)<http://alinhavado.wordpress.com/%28pt-br%29>| > http://blog.codevader.com/(en) <http://blog.codevader.com/%28en%29> > > > > On Sat, Dec 6, 2008 at 7:11 PM, Jaikishan Jalan <jai....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > Hello, > > > > > I have a button which when clicks sends exam_id to server. The method > > > queries results of all the students who has appeared in this exam (No. > of > > > student > 30). I want to now print this data at client side. I am > confused > > > how do I achieve this? I dont want to display this data at client > side... > > > instead, I just want to show a progress bar that printing in progress > and > > > once I get all the data from server, I need to print it. > > > > > Any pointers to get started on this? > > > > > -- > > > Thanks, > > > Jaikishan > > >-- Thanks, Jaikishan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---