/** * GridColumnFieldMapper::render() * * @param $object * @return string */ public function &render($object) { $grid = new SubGrid(); $grid->NewColumn('FieldMapper', $this->title, $this->params); $getter = 'get' . $this->params['link'] . 'Collection'; $result = $grid->render($object->{$getter}()); return $result; }
/** * @param string $name * @param null|string $label * @return SubGrid * @throws DuplicateSubGridException */ public function addSubGrid($name, $label = NULL) { if (!empty($this['subGrids']->components[$name]) || in_array($name, $this->getSubGrids())) { throw new DuplicateSubGridException("SubGrid {$name} already exists."); } $self = $this; $primaryKey = $this->primaryKey; $subGrid = new SubGrid($this['subGrids'], $name); $subGrid->setName($name)->setLabel($label); if ($this->activeSubGridName == $name) { $subGrid->setClass("grid-subgrid-close"); $subGrid->setClass(function ($row) use($self, $primaryKey) { return $row[$primaryKey] == $self->activeSubGridId ? "grid-subgrid-close" : "grid-subgrid-open"; }); $subGrid->setLink(function ($row) use($self, $name, $primaryKey) { $link = $row[$primaryKey] == $self->activeSubGridId ? array("activeSubGridId" => NULL, "activeSubGridName" => NULL) : array("activeSubGridId" => $row[$primaryKey], "activeSubGridName" => $name); return $self->link("this", $link); }); } else { $subGrid->setClass("grid-subgrid-open")->setLink(function ($row) use($self, $name, $primaryKey) { return $self->link("this", array("activeSubGridId" => $row[$primaryKey], "activeSubGridName" => $name)); }); } return $subGrid; }