title: How to prepare grid view columns array using model or controller in yii2?
body: <p>I am using yii2 grid view widget like below</p>
  
  <pre><code>&lt;?= GridView::widget([
      'dataProvider' =&gt; $dataProvider,
      'filterModel' =&gt; $searchModel,
      'columns' =&gt; [
          ['class' =&gt; 'yii\grid\SerialColumn'],
          [
              'attribute' =&gt; 'name',
              'visible' =&gt; empty($visbleValue) ? '1':'0',
              'value' =&gt; function($model){                   
                  return $model-&gt;name;
              }
          ],         
          [   
              'attribute' =&gt; 'account',
              'visible' =&gt; empty($visbleValue) ? '0':'1',
              'value' =&gt; function($model){                
                  return implode(', ', ArrayHelper::map($model-&gt;accounts, 'id', 'account_name'));
              }
          ],
          [
              'attribute' =&gt; 'Document',
              'visible' =&gt; empty($visbleValue) ? '1':'0',
              'value' =&gt; function($model, $index, $column) {
                 return Document::findOne(['user_id' =&gt; $model-&gt;id,])-&gt;document_name;
              },
              'label' =&gt; 'Document',
          ],
  
          ['class' =&gt; 'yii\grid\ActionColumn'],
      ],
  ]); ?&gt;
  </code></pre>
  
  <p>This all are working fine, but i want prepare columns array values(attribute values like name,account,document) using model or controller, how to do that.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public function actionVerficationDetails()
  {      
      $session = Yii::$app-&gt;session;
      $visbleValue= $session-&gt;get('visbleValue');
      $searchModel = new VerficationDetailsSearch();
      $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;queryParams);
      return $this-&gt;render('VerficationDetails', [
          'searchModel' =&gt; $searchModel,
          'dataProvider' =&gt; $dataProvider,
          'visbleValue' =&gt; $visbleValue,
      ]); 
  }
  </code></pre>
  
  <p>Here i print dataprovider it will print some empty query objects, no data will come. Please help anyone.</p>