APY / APYDataGridBundle

Symfony Datagrid Bundle
MIT License
492 stars 344 forks source link

Column custom Value Render #966

Closed wohral closed 7 years ago

wohral commented 7 years ago

Is there any way, how to make custom rendering of value in grid. For example I would like to render text field, and put the icon in front of text.

$someTextColumn->setCustomValueRender(function($item) {
    return "<i class='icon'>".$item->getValue()."</i>";
});

Something like used in Ubladoo datagrid for Nette https://ublaboo.org/datagrid/column#renderer

Or I have to specify my custom Type? and define custom class and block?

DonCallisto commented 7 years ago

You have to specify your own custom column type and its rendering. In this case you can extend TextColumn, use a different column type name

public function getType()
{
    return 'class_icon';
}

and put the html part into render

wohral commented 7 years ago

I thought I have to do it this way. Anyway, thank you :)