Skip to content

Magento 2 Convert backend admin grid to use joint table

What are the step I need to take to convert my backend admin grid to use a joint table I have my grid example with column id and name

id comes from the mainTable and name from the secondtable:
enter image description here

I have added to my collection:

$this->getSelect()->joinLeft(
        ['secondTable' => $this->getTable('second_table')], //2nd table name by which you want to join
        'main_table.entity_id = secondTable.main_table_entity_id', // common column which available in both table 
        '*' // '*' define that you want all column of 2nd table. if you want some particular column then you can define as ['column1','column2']
    );

This works well on the Frontend but not sure what I am missing to make it work on the admin grid?