⚠ 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

Extra button



ashish
  • profile picture
  • Member

Posted 06 May 2013 - 12:24 PM

I want to add save as pdf button instead of print button ...how to do this


davidoster
  • profile picture
  • Member

Posted 07 May 2013 - 09:02 AM

/topic/806-export-data-via-excel-pdf/


ashish
  • profile picture
  • Member

Posted 10 May 2013 - 05:45 AM

sir,Thanks for ur reply. I know the code for create pdf but what I want is to know about the "print" button. How to change the label from 'print' to 'save as pdf' and where to add my code for save as pdf...please help me about this..

         Thanking You..  


heruprambadi
  • profile picture
  • Member

Posted 10 May 2013 - 07:10 AM

just change the label, right ?

change :

$lang['list_print'] 	= "Print";

in :

htdocs\grocerycrud\assets\grocery_crud\languages\your_language.php

davidoster
  • profile picture
  • Member

Posted 10 May 2013 - 09:43 AM

sir,Thanks for ur reply. I know the code for create pdf but what I want is to know about the "print" button. How to change the label from 'print' to 'save as pdf' and where to add my code for save as pdf...please help me about this..

         Thanking You..  

 

Go to assets\grocery_crud\themes\your theme\views

Under this directory you will find the file list_template.php.

There you will find the code for the Excel and Print buttons.


davidoster
  • profile picture
  • Member

Posted 10 May 2013 - 09:46 AM

just change the label, right ?

change :

$lang['list_print'] 	= "Print";

in :

htdocs\grocerycrud\assets\grocery_crud\languages\your_language.php

 

There is also this, http://www.grocerycrud.com/documentation/options_functions/set_lang_string


heruprambadi
  • profile picture
  • Member

Posted 11 May 2013 - 01:45 AM

iiyap ! i think i have to re-read grocery crud documentation.


ashish
  • profile picture
  • Member

Posted 11 May 2013 - 02:20 AM

thanks both of u a lot....the code some what complicated but I tried to understand....at last my problem get solve


ashish
  • profile picture
  • Member

Posted 11 May 2013 - 09:30 AM

sir,below code executed when I set the print button.....but where's the code when I click the print button.......
 
<a class="print-anchor" data-url="<?php echo $print_url; ?>">
                <div class="fbutton">
                    <div>
                        <span class="print"><?php echo $this->l('list_print');?></span>
                    </div>
                </div>
            </a>

heruprambadi
  • profile picture
  • Member

Posted 11 May 2013 - 09:45 AM

i think what i and davidoster posted was very clear up there.

 

or simply, just write it in your controller :

$crud->set_lang_string('list_print','Save as PDF');

ashish
  • profile picture
  • Member

Posted 11 May 2013 - 11:03 AM

heruprambadi sir, i got it that very clearly...but what i want is to edit the print code with my code so I want location where it is present..i changed the name from print to save as pdf already

heruprambadi
  • profile picture
  • Member

Posted 11 May 2013 - 16:15 PM

ok. i don't know if it safe or not, but try this :

1. in application/library/grocery_crud.php, find :

protected function getExportToExcelUrl()
	{
		
		return $this->state_url('export');
	}

   and change into :

protected function getExportToExcelUrl()
	{
		if (isset($this->custom_add_url))
		{
			return site_url($this->custom_export_url);
		}
		return $this->state_url('export');
	}

2. then, in your controller, write :

$crud->custom_export_url ='your_url_to_call_export_to_pdf_function';

it works like callback for button function.