add_action

void add_action( string $label,  string $image_url , string $link_url , string $css_class ,  mixed $url_callback)

Add an action/operation to the list table. The way to do that its simple:

  1. add the label of your subject, for example "Photo Gallery".
  2. add an image url . Notice that in the flexigrid theme is a required field.
  3. add your custom url. This url will be connected with the site_url function and the primary key. For example if you add 'my_controller/photo/' then it will transform to site_url('my_controller/photo/'.$primary_key_for_each_row)
  4. add a CSS class. Remember that at the theme of datatables a CSS class includes images , for example :  ui-icon-image, ui-icon-plus, e.t.c.
  5. You can even add your own url callback. If you don't want the default transformation of the url, you can use this paremeter to add your own algorithm of the url transformation. 

Example:

 
function offices_management_with_actions()
{
    $crud = new grocery_CRUD();
 
    $crud->set_theme('datatables');
    $crud->set_table('offices');
    $crud->set_subject('Office');
    $crud->required_fields('city');
    $crud->columns('city','country','phone');
 
    $crud->add_action('More', '', 'demo/action_more','ui-icon-plus');
    $crud->add_action('Photos', '', '','ui-icon-image',array($this,'just_a_test'));
    $crud->add_action('Smileys', 'http://www.grocerycrud.com/assets/uploads/general/smiley.png', 'demo/action_smiley');
 
    $output = $crud->render();
 
    $this->_example_output($output);
}
 
function just_a_test($primary_key , $row)
{
    return site_url('demo/action/action_photos').'?country='.$row->country;
}
 

And the result will be:

Note: The below example is an iframe so it might appeared with a scroll bar. If you like you can view the example on a new tab