⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

one filed in two set_relation



zstyle

zstyle
  • profile picture
  • Member

Posted 18 July 2017 - 07:32 AM

first table : agency
id
user_id
service_id
...
...

second table: users
id
username
...
...

third table: user_profile
id
user_id
firstname
lastname
...
...

part of code

$this->grocery_crud->set_table('agency');

//working search & sort in this column
$this->grocery_crud->set_primary_key('user_id','user_profile');
$this->grocery_crud->set_relation('user_id', 'user_profile', '{firstname} {lastname}');
$this->grocery_crud->display_as('user_id', 'User');

//dont working search & sort in this column
$this->grocery_crud->callback_column('user_name', [$this, '_callback_agencies_team_user_name_column']);


public function _callback_agencies_team_user_name_column($value, $row)
    {
        $this->load->model('dx_auth/users');
        $user = $this->users->get_user_by_id($row->user_id)->row_array();
        return $user['username'];
    }

How way  I use two set_relation for one filed, for working sort & search

$this->grocery_crud->set_relation('user_id', 'user_profile', '{firstname} {lastname}');

$this->grocery_crud->set_relation('user_id', 'users', 'username');

Help me please, Thanks.