How to hide rows from Yii2 GridView based on user permissions?

I'm trying to hide rows from a GridView based on user permissions (RBAC). (Yii::$app->user->can('readModel', ['model' => $model]);)

I assumed i have to add some filters to the search model, but i can't find out how i can add this filter to the query. Maybe there is an easier solution that i haven't found yet, like adding an argument to the GridView call?

Docs don't really help me understand this specific situation either.

Thanks in advance.


a way clould be based on assign a proper class to rows using row options

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
        .........
        ['class' => 'yii\grid\ActionColumn'],
    ],
   'rowOptions'=>function ($model){
        $class= (Yii::$app->user->can('readModel',  ['model' => $model]) ? 'hide' : 'swow';
         return $class;
    },