yii\widgets\ListView::renderItems PHP Method

renderItems() public method

Renders all data models.
public renderItems ( ) : string
return string the rendering result
    public function renderItems()
    {
        $models = $this->dataProvider->getModels();
        $keys = $this->dataProvider->getKeys();
        $rows = [];
        foreach (array_values($models) as $index => $model) {
            $rows[] = $this->renderItem($model, $keys[$index], $index);
        }
        return implode($this->separator, $rows);
    }

Usage Example

 /**
  * @inheritdoc
  */
 public function renderItems()
 {
     if ($this->columns < 2) {
         parent::renderItems();
         return;
     }
     $models = $this->dataProvider->getModels();
     $keys = $this->dataProvider->getKeys();
     $rows = [];
     $layouts = ArrayHelper::getValue($this->columnsLayout, $this->columns, []);
     $this->itemOptions = empty($this->itemOptions) ? $this->buildItemOptions($layouts) : $this->itemOptions;
     foreach (array_values($models) as $index => $model) {
         $rows[] = $this->renderItem($model, $keys[$index], $index);
         // set a clearfix breaks for responsive columns
         if ($this->createRows) {
             $clearRows = $this->buildClearFixTag($layouts, $index + 1);
             if (empty($clearRows)) {
                 continue;
             }
             $rows[] = implode("\n", $clearRows);
         }
     }
     return Html::beginTag('div', $this->rowOptions) . implode($this->separator, $rows) . Html::endTag('div');
 }
All Usage Examples Of yii\widgets\ListView::renderItems