yii\grid\GridView::guessColumns PHP Method

guessColumns() protected method

This function tries to guess the columns to show from the given data if [[columns]] are not explicitly specified.
protected guessColumns ( )
    protected function guessColumns()
    {
        $models = $this->dataProvider->getModels();
        $model = reset($models);
        if (is_array($model) || is_object($model)) {
            foreach ($model as $name => $value) {
                if ($value === null || is_scalar($value) || is_callable([$value, '__toString'])) {
                    $this->columns[] = (string) $name;
                }
            }
        }
    }