Skip to content

Latest commit

 

History

History
96 lines (63 loc) · 2.05 KB

template.md

File metadata and controls

96 lines (63 loc) · 2.05 KB

Table of contents

Templates

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

Template:

{extends $originalTemplate}

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


{* Another latte code... *}

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}

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}

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}

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}

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}{/}