⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Add Print button on the read page



archerwisdom
  • profile picture
  • Member

Posted 10 October 2013 - 10:30 AM

Hi,

 

Currently we only have PRINT button on the listing page. 

Can I add print button to the READ page that read only one record?

 


Amit Shah
  • profile picture
  • Member

Posted 10 October 2013 - 11:48 AM

Hi there,

 

Nice idea - yes u surely can add a print button on the print page - you can modify the assets/grocery_crud/themes/<theme>/views/read,php

here u can add the print button and the relevant print functionality :)

 

Happy GCing


archerwisdom
  • profile picture
  • Member

Posted 10 October 2013 - 16:19 PM

Thanks for reply.

May I know what is the code for adding Print button ?


archerwisdom
  • profile picture
  • Member

Posted 14 October 2013 - 03:33 AM

Any help and guidance on printing codes are greatly appreciated.


Amit Shah
  • profile picture
  • Member

Posted 14 October 2013 - 09:29 AM

assets/grocery_crud/themes/flexgrid/views/read.php

in there - you will find the following code

<input type='button' value='<?php echo $this->l('form_back_to_list'); ?>' class="btn btn-large back-to-list" id="cancel-button" />

 

below the same - u can add

<input type='button' onclick = "window.print()" value='Print' class="btn btn-large" id="cancel-button" />

 

that should do the trick


archerwisdom
  • profile picture
  • Member

Posted 16 October 2013 - 10:22 AM

Hi Amit,

 

Thanks for reply.

The window.print() function is the normal javascript that will print the whole screen incuding the header and footer.

But when I look at the Print button from the Listing all records, using the datables theme, it only print the table without the header and footer when we click on the Print button.

Is it possible to have the same print feature on the Read record page? 


Amit Shah
  • profile picture
  • Member

Posted 22 October 2013 - 11:04 AM

Sorry was away on loads of project work so - there was delay in answering out.

 

Well there is a way around but then you need to alter the GC library / extend it in the right way if not to alter it

Then - add a function to handle print of read page / view with a new view (print.php)

There you only add what you want to print and nothing much.

 

here is a forum post where i shared an example as how to add a view button to the GC library before the read button came in.

 

 

The same way you can use / extend the system to add a print_read functionality and achieve your functionality

 

 

There is another way around that you can achieve the same functionality by modifying the output script here

 

The idea shared with the script link above was when you want to print, hide all the elements and then show only the elements you wish to / plan to keep it active.

Then when user returns back from print mode - restore all the elements back to its state.

 

Choose whatever solution you like.

 

Happy GCing


archerwisdom
  • profile picture
  • Member

Posted 17 November 2013 - 14:33 PM

Thanks Amit. I will try that.