In grocery crud, searching is not happening for related tables.
Searching is only happening for that table fields.
function index() {
$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('table_name');
$crud->display_as('id','Name');
$crud->callback_column('id', array($this, 'changeName'));
$output = $crud->render();
}
function changeName($value, $row) {
$new = $this->db->select('name')->where('another_table.id', $row->id)->get('another_table')->result();
if(!empty($new)){
return $new[0]->name;
} else {
return $value;
}
}
Here search is not happening for name.
Any one have solution for this ?
Thanks in advance.
Hi @DelvinPaul: I hope your problem is solved. Just in case if its not solved, try debugging your query inside changeName
using
log_message('info','Query: '.$this->db->last_query());
log_message('info','Result Returned: '.print_r($new,true));
put these statements after the following line in your changeName function:
$new = $this->db->select('name')->where('another_table.id', $row->id)->get('another_table')->result();
And don't forget to change $config['log_threshold'] = 3;
in your config file. After debugging, please update your question for more clarity so that we can answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With