contributte / datagrid

:muscle: DataGrid for Nette Framework: filtering, sorting, pagination, tree view, table view, translator, etc

Home Page:https://contributte.org/packages/contributte/datagrid/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in foreign key through 2 tables

krumld opened this issue · comments

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
  • ...