Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching not happening in grocery crud

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.

like image 521
Delvin Paul Avatar asked Nov 03 '22 03:11

Delvin Paul


1 Answers

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.

like image 96
Elavarasan Muthuvalavan - Lee Avatar answered Nov 09 '22 15:11

Elavarasan Muthuvalavan - Lee