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.
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~