Table of contents

# Extending

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');
1

Template:

{extends $originalTemplate}

{block data}
	{foreach $items as $item}
		{foreach $columns as $key => $column}
			{$column->render($item)}
		{/foreach}
	{/foreach}


{* Another latte code... *}
1
2
3
4
5
6
7
8
9
10
11

# Column definition

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}

1
2
3
4
5
6
7
8
9
10

This will overwrite native rendering of ID column ($grid->addColumn('id', 'Id');).

# Column header definition

Or you can define column header template:

{extends $originalTemplate}

{define col-id-header}
	This is <strong>ID</strong> column
{/define}

1
2
3
4
5
6

# Containing div class definition

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}
1

# Table class definition

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}
1

# Icons definition

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}{/}
1
2
3
4
5