Grido\Components\Columns\Column::getCellPrototype PHP Method

getCellPrototype() public method

Returns cell prototype ( html tag).
public getCellPrototype ( mixed $row = NULL ) : Nette\Utils\Html
$row mixed
return Nette\Utils\Html
    public function getCellPrototype($row = NULL)
    {
        $td = $this->cellPrototype;
        if ($td === NULL) {
            //cache
            $td = $this->cellPrototype = \Nette\Utils\Html::el('td')->setClass(['grid-cell-' . $this->getName()]);
        }
        if ($this->cellCallback && $row !== NULL) {
            $td = clone $td;
            $td = call_user_func_array($this->cellCallback, [$row, $td]);
        }
        return $td;
    }

Usage Example

 /**
  * @param \Grido\Components\Columns\Column $column
  * @param Callable $recordCallback
  * @return \Grido\Components\Columns\Column
  */
 public function setupAsMultirecord(\Grido\Components\Columns\Column $column, $recordCallback)
 {
     $column->getCellPrototype()->class[] = 'multirecord';
     $column->setCustomRender(function ($row) use($recordCallback) {
         $return = Html::el('ul', ['class' => 'select2-choices']);
         foreach ($recordCallback($row) as $item) {
             $li = Html::el('li', ['class' => 'select2-search-choice']);
             $li->create('div', $item);
             $return->add($li);
         }
         return $return;
     });
     return $column;
 }
All Usage Examples Of Grido\Components\Columns\Column::getCellPrototype