⚠ 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

custom action button doesn't shown



z.kerry
  • profile picture
  • Member

Posted 07 May 2018 - 11:55 AM

Hello, new GC user here~

 

I just learn how to use Grocery Crud a little while ago (and in programming as well). So... I tried to create a custom action button for the table using the add_action() function, yet the button doesn't appear in the action column of the table and yet the system doesn't return any error fatal errors.

 

Below is the said code;

 

 
public function on_progress()
{
$this->grocery_crud->set_model('Custom_query_model');
$this->grocery_crud->set_table('complaints');
$this->grocery_crud->set_theme('flexigrid');
$this->grocery_crud->basic_model->set_query_str("SELECT complaints.*, category.category_name,facilities_services. fs_name, trade.trade_name,
problem_type.problem_type,level.level, users.name,contractor.name
FROM complaints
LEFT JOIN category ON complaints.category_id = category.id
LEFT JOIN facilities_services ON complaints.fs_id = facilities_services.id
LEFT JOIN users ON complaints.report_by = users.id
LEFT JOIN trade ON complaints.trade_id = trade.id
LEFT JOIN problem_type ON complaints.problem_type_id = problem_type.id
LEFT JOIN level ON complaints.level_id = level.id
                                            LEFT JOIN contractor ON complaints.contractor_id = contractor.id
WHERE category.id = facilities_services.category_id
AND facilities_services.id = problem_type.fs_id AND 
complaints.report_by = users.id
");
$this->grocery_crud->columns('id','category_name','fs_name', 'trade_name', 
'problem_type', 'level', 'users.name', 'event_datetime',
'event_completed', 'contractor.name','work_status',
'complaint_photo','completion_photo','overall_status'
);
 
 
 
$this->grocery_crud->display_as('id','Complaint Id');
$this->grocery_crud->display_as('category_name', 'Category');
$this->grocery_crud->display_as('fs_name','Facilities/Services');
$this->grocery_crud->display_as('trade_name','Problem Category');
$this->grocery_crud->display_as('problem_type','Problem Type');
$this->grocery_crud->display_as('level', 'Level');
$this->grocery_crud->display_as('users.name','Report By');
$this->grocery_crud->display_as('contractor.name','Craftsmen');
$this->grocery_crud->add_action('this','','','',array($this,'assign_Craftsmen'));
 
$this->grocery_crud->callback_column('complaint_photo', array($this,'show_ComplaintImage'));
$this->grocery_crud->callback_column('completion_photo', array($this,'show_CompleteImage'));
 
function show_ComplaintImage($value)
{
return "<img src='".$value."' width='100px'>";
}
 
function show_CompleteImage($value)
{
return "<img src='".$value."' width='100px'>";
}
 
function assign_Craftsmen($primary_key, $row)
{
 
 
}
 
 
$output = $this->grocery_crud->render();
 
$this->load->view('templates/header');
$this->load->view('templates/header_grocery_crud');
$this->load->view('templates/header_menu');
$this->load->view('forms/updateForm', $output);
$this->load->view('templates/footer_grocery_crud');
$this->load->view('templates/footer');
}
 
Thanks a lot~

 


runar-orested
  • profile picture
  • Member

Posted 21 May 2018 - 15:14 PM

Check what theme you are using: If you are using flexigrid, it does not show the text label and css icon, only the image which URL you put in the second field.

 

Just try this code from the documentation:

 

    $crud->add_action('Smileys', 'http://www.grocerycrud.com/assets/uploads/general/smiley.png' 'demo/action_smiley');

 

You will see that only the icon (smiley.png) appears.

 

Though it would be nice to know from which icon collection the icons from the themes come from, so we could add others. Mainly the ones from flexigrid, which are coloured ones and harder to find matching ones.


runar-orested
  • profile picture
  • Member

Posted 21 May 2018 - 15:24 PM

Oh, I forgot. If you just want to leave the text and no icon, put a dumb url on it, dont leave it empty:

 

$crud->add_action('Smileys', '#' 'demo/action_smiley');