code: 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;
                  }
              }
          }
      }
docs: This function tries to guess the columns to show from the given data
  if [[columns]] are not explicitly specified.