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);
}
}