5

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.

Delvin Paul
  • 359
  • 3
  • 13
  • how many results are retuned in your `changeName` query? How many results do you expect returned? – brightintro Mar 19 '13 at 13:58
  • Hai ekims, changeName is only for change id to respective names. After this changing we can't search these names... Only we can search the respective table fields... My requirement is to search these names in crud datagrid. – Delvin Paul Mar 22 '13 at 10:59

2 Answers2

2

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.

0

Use

$crud->set_theme('datatables');

Instead of

$crud->set_theme('flexigrid');

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

Shoaib Ahmed
  • 747
  • 12
  • 28
  • Hows that possible man datables theme is using Jquery datatables and if your grid is populating properly it must be searcahble.. – Shoaib Ahmed Nov 24 '13 at 20:37