You can set a callback to manipulate the render of a cell.
If the callback returns nothing, the cell will be empty.
<?php
...
$grid->setSource($source);
$grid->getColumn('my_column_id')->manipulateRenderCell($callback);
...
|parameter|Type|Default value|Description| |:--:|:--|:--|:--|:--| |callback|\Closure or callable|null|Callback to manipulate rows. Null means no callback.|
|parameter|Type|Description| |:--:|:--|:--|:--|:--| |value|string|The value of the cell| |row|instance of Row|The current row| |router|instance of the router engine|The symfony router|
<?php
...
$grid->setSource($source);
$grid->getColumn('my_column_id')->manipulateRenderCell(
function($value, $row, $router) {
return $router->generate('_my_route', array('param' => $row->getField('column4')));
}
);
...
Note: You can fetch hidden columns if the source attribute is set to true.
Use this method to fill an empty column:
<?php
...
$grid->setSource($source);
// Add a column with a rendering callback
$MyColumn = new TextColumn(array('id' => 'Another Column'));
$MyColumn->manipulateRenderCell(function($value, $row, $router) {
return $router->generate('_my_route', array('param' => $row->getField('column4')));}
);
$grid->addColumn($MyColumn);
...