title: How to join two tables and get values in Yii2 gridview
body: <p>I'm using Yii2 <strong>gridview widget</strong> to display the data.</p>
  
  <p>I'm using two tables named as <strong>message</strong> and <strong>message_trigger</strong>.</p>
  
  <p>In <strong>message</strong> table columns are <code>object_model</code>, <code>Object_id</code>. </p>
  
  <p>In <strong>message_trigger</strong> the column are <code>object_id</code>, <code>object_name</code>.</p>
  
  <p>The grid get the values from the table <strong>message</strong>. So grid fields are <code>Object_model</code>, <code>Object_id</code>. </p>
  
  <p>Now my problem is I need to show <code>Object_name</code> from the table <code>message_trigger</code> based on the <code>object_id</code> from the table <strong>message</strong>.</p>
  
  <p>In my form I have used grid like this</p>
  
  <pre><code>&lt;?= GridView::widget([
      'dataProvider' =&gt; $dataProvider,
      'filterModel' =&gt; $searchModel,
      'columns' =&gt; [
          ['class' =&gt; 'yii\grid\SerialColumn'],
          'object_model',
          'object_id',
          ['class' =&gt; 'yii\grid\ActionColumn', 'template' =&gt; '{view} {update} {delete} '],
      ],
  ]); ?&gt;
  </code></pre>
  
  <p>In model I have used </p>
  
  <pre><code>public function search($params){
      $query = AlertTrigger::find()-&gt;where(['alert_id'=&gt;$params['id']])-&gt;andWhere(['!=','status',2]);
      $dataProvider = new ActiveDataProvider([
          'query' =&gt; $query,
      ]);
  }
  </code></pre>