Yii2 GridView Filtering on Relational Column

To filter a Yii2 GridView by a relational column, you can make use of the joinWith() method in the query. Here's an example of how you can achieve this:

$query = YourModel::find()->joinWith('relationName');

$dataProvider = new ActiveDataProvider([
    'query' => $query,
]);

// Apply the filter
$query->andFilterWhere(['related_table.column_name' => $filterValue]);

// Render the GridView
echo GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        // Specify the columns you want to display
    ],
]);

Replace YourModel with the name of your model class, relationName with the name of the relation you want to join, related_table with the name of the related table, and column_name with the name of the column you want to filter.

This should allow you to filter the GridView based on a relational column.