⚠ 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 action in list view for each line



kat
  • profile picture
  • Member

Posted 17 January 2018 - 09:43 AM

I am a beginner in CI and grocery crud I want to add action print like this https://www.grocerycrud.com/documentation/options_functions/add_action for each line next to the button edit and delete and view to print only the form displayed

I am a beginner in CI and grocery crud I want to add action print for each line next to the button edit and delete and view to print only the form displayed


darkstalker
  • profile picture
  • Member

Posted 17 January 2018 - 18:46 PM

you need :

 

1) $crud->add_action('Print form', '', '','ui-icon-image',array($this,'print_a_form'));

 

2) a function "print_a_form" like

 

function print_a_form($primary_key , $row)
{
}

 

where you can call a method (that you need to write) to get the form data based on $primary_key for example,

and then call a view (that you need to write) to show the data as you like and show also a print button that print what you see in the view.

 

so:

 

1) add_action

 

2) function to call from add_action

 

3) method to get the data

 

4) view to show the data and print button

 

-----------------

instead of point 4, remember that you can see the data already inside grocery crud, so you can directly insert the print command inside the function at point 2, after you got the data you want

 

Hope this can help you go in the right direction. Then you need to practice.


darkstalker
  • profile picture
  • Member

Posted 17 January 2018 - 18:49 PM

another tip:

 

"the data you want" ( the data of the row you want to print) are already inserted in the $row variable inside the function you call with the add_action.

If you only need that data displayed in the grocery crud row, you don't need the method at point 3 too. You just need to print inside that function at point 2


kat
  • profile picture
  • Member

Posted 19 January 2018 - 11:52 AM

thanks darkstalker for your reply but I want to have a button next to 'back to list' so that I could print this form

and I can't edit in the kernel libraries of grocery crud