kartik\grid\FormulaColumn::col PHP Méthode

col() public méthode

Gets the value of a column
public col ( integer $i, array $params = [] ) : string
$i integer the index of the grid column (the first column in the grid will be zero indexed). Note a column's index is to be considered, even if the `visible` property is set to false.
$params array which will contain these keys: - `model`: _yii\base\Model`, the data model being rendered - `key`: _string|object_, the key associated with the data model - `index`: _integer_, the zero-based index of the data item among the item array returned by [[GridView::dataProvider]]. - widget: _FormulaColumn_, the current column widget instance
Résultat string
    public function col($i, $params = [])
    {
        if (empty($this->grid->columns[$i])) {
            throw new InvalidConfigException("Invalid column index {$i} used in FormulaColumn.");
        }
        if (!isset($this->value) || !$this->value instanceof \Closure) {
            throw new InvalidConfigException("The 'value' must be set and defined as a `Closure` function for a FormulaColumn.");
        }
        /** @var DataColumn $col */
        $col = $this->grid->columns[$i];
        if ($col === $this) {
            throw new InvalidConfigException("Self-referencing FormulaColumn at column {$i}.");
        }
        $model = null;
        $key = null;
        $index = null;
        extract($params);
        if ($index == self::SUMMARY) {
            return $col->getPageSummaryCellContent();
        } elseif ($index == self::FOOTER) {
            return $col->getFooterCellContent();
        } else {
            return $col->getDataCellValue($model, $key, $index);
        }
    }