Add a custom action control
For more about the parameters of add_action, you can read the add_action method documentation.
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', 'https://www.grocerycrud.com/v1.x/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
You can use add_action with the flexigrid theme also. But remember you MUST add an image url to have good result.
Below I just copied the functions that I used for the actions:
function action_photos() { //Just a quick filtering of $_GET $country = preg_replace("/([^a-zA-Z0-9\.\-\_]+?){1}/i", ' ', $_GET['country']); echo "<div style='font-size:16px;font-family:Arial'>"; echo "Just a test function for photos button and country: <b>".$country."</b><br/>"; echo "<a href='".site_url('demo/offices_management_with_actions')."'>Go back to example</a>"; echo "</div>"; die(); } function action_more($id) { echo "<div style='font-size:16px;font-family:Arial'>"; echo "Just a test function for more button and id: <b>".(int)$id."</b><br/>"; echo "<a href='".site_url('demo/offices_management_with_actions')."'>Go back to example</a>"; echo "</div>"; die(); } function action_smiley($id) { echo "<div style='font-size:16px;font-family:Arial'>"; echo "Just a test function for action button smiley and id: <b>".(int)$id."</b><br/>"; echo "<a href='".site_url('demo/offices_management_with_actions')."'>Go back to example</a>"; echo "</div>"; die(); }