title: yii2 create view to display model
body: <p>I'am trying to implement the demos.krajee.com/grid-demo in a project but i am getting stuck creating the grid for the detail view.</p>
  
  <p>It is a grid and when use the expandRow functionality of the extention I need to get all the related records from another table base in the id (master - detail scenario)</p>
  
  <p>In the controller i have this function that it is working fine to get all records for an specific id:</p>
  
  <pre><code>    public function actionDetail() {
      $searchModel = new AttendanceSearch();
      $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;queryParams);
      if (isset($_POST['expandRowKey'])) {
          $IDcustomers = Yii::$app-&gt;request-&gt;post('expandRowKey');
  
      $model = Attendance::find()
              -&gt;where(['IDcustomers' =&gt; $IDcustomers])
              -&gt;all();            
          return $this-&gt;renderPartial('_attendance-details', ['model'=&gt;$model]);
  
      } else {
          return '&lt;div class="alert alert-danger"&gt;No data found&lt;/div&gt;';
      }
  }
  </code></pre>
  
  <p>The problem now is how to create the view (_attendance-details) from the $model and get all the records display in a grid.</p>
  
  <p>if i use DetailView with the first element of $model works fine:</p>
  
  <pre><code>        &lt;?= DetailView::widget([
      'model' =&gt; $model[0],
      'attributes' =&gt; [
          'IDattendance',
          'IDcustomers',
          'date',
          'doctor',
          'lawyer',
      ],
  ]) ?&gt;
  </code></pre>
  
  <p>But when i try to use grid i need the dataprovider and i can't make it work with the $model i am passing.</p>
  
  <p>I am very new to yii so any guide will be much appreciated.</p>
  
  <hr>
  
  <p>I tried vitalik and work perfect</p>