简体   繁体   中英

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.

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.

Use

$crud->set_theme('datatables');

Instead of

$crud->set_theme('flexigrid');

and u will have it working . This problem is only with flexgrid theme.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM