Table of contents
When you set custom datagrid template, you will probably want to extend it. There are some blocks
defined, so you can extend just some blocks. Presenter:
$grid->setTemplateFile(__DIR__ . '/../../custom_datagrid_template.latte');
Template:
{extends $originalTemplate}
{block data}
{foreach $items as $item}
{foreach $columns as $key => $column}
{$column->render($item)}
{/foreach}
{/foreach}
{* Another latte code... *}
Or you can define column template by defining special block(s):
{extends $originalTemplate}
{define col-id}
:)
{/define}
{define col-title}
{$item->title} {* displays the title value *}
{/define}
This will overwrite native rendering of ID column ($grid->addColumn('id', 'Id');
).
Or you can define column header template:
{extends $originalTemplate}
{define col-id-header}
This is <strong>ID</strong> column
{/define}
By default, the containing div has this class: datagrid datagrid-{$control->getFullName()}
. You can change that in {block #datagrid-class}
:
{block datagrid-class}datagrid datagrid-{$control->getFullName()} custom-class{/block}
By default, table has this class: table table-hover table-striped table-bordered table-sm
. You can change that in {block #table-class}
:
{block table-class}table table-hovertable-condensed table-bordered{/block}
Some icons are also surrounded by `{block icon-*}` macro. You can overwrite these blocks with your icons. The blocks are:
{block icon-sort}{/}
{block icon-sort-up}{/}
{block icon-sort-down}{/}
{block icon-caret-down}{/}
{block icon-chevron}{/}