datagrid icon indicating copy to clipboard operation
datagrid copied to clipboard

Error in foreign key through 2 tables

Open krumld opened this issue 4 years ago • 0 comments
trafficstars

Hi, i'm trying to set through column for addColumnText. I wrote QueueGrid and I need get column with environment name.

My code: $grid->addColumnText('environment_id', 'Environment', 'file.environment.name')->setFilterText('file.environment.name');

I'm getting this error:

Cannot read an undeclared column 'file.environment.name'

If I change third parameter of addColumnText to 'file.environment:file_id', there is no error. But datagrid doesn't generate LEFT JOIN in SQL. It generates LEFT JOIN only when filtering environment name.

My question: Why does the 'file.environment.name' in filter generates LEFT JOIN, but same relation in through column throws error? Is there possibility to create relation over 2 tables?

My tables: queue

  • id
  • file_id
  • ...

file

  • id
  • environment_id
  • ...

environment

  • id
  • name
  • ...

krumld avatar Sep 21 '21 07:09 krumld