Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summary row at the end of the Grid #42

Open
tprochazka opened this issue Feb 7, 2021 · 3 comments
Open

Summary row at the end of the Grid #42

tprochazka opened this issue Feb 7, 2021 · 3 comments

Comments

@tprochazka
Copy link

I often need some summary row at the end of the grid with total or average values.
I'm doing it usually by adding one more row with the special class to style it differently.
But I don't found a way how to handle it if I have some special formatting rule for one column, which should not apply to the last row.

Like

{define body-cell-month-content}
    <a href="{plink :month $record->year, $record->month}">{$$recordVariable |getValue:$columnName:FALSE}</a>
{/define}

The last row should not be clickable. Is there some official way how to do it?

@uestla
Copy link
Owner

uestla commented Feb 8, 2021

You could overwrite the #footer-row block:

{** @param string $footerInfo *}
{define footer-row}
<tr>
<td colspan="{$columnCount}" class="container footer-cell">
<div class="row">
{if $hasGroupActions}
{include #group-action-buttons}
{/if}
{if $grid->getPageCount() > 1}
{include #pagination}
{/if}
{$footerInfo |noescape}
</div>
</td>
</tr>
{/define}

Something like

{define footer-row}

	<tr>
		<td colspan="{$columnCount}">
			{* ... *}
		</td>
	</tr>

	{include parent}

{/define}

@tprochazka
Copy link
Author

tprochazka commented Feb 14, 2021

Thanks! It is also an interesting way. I'm just not sure if there is just not possible to have access to data directly from this template.
Currently, I end up with something like this. I know. Very ugly hack ;-)

{define body-cell-month-content}
    {if !isset($record->rowClass) || $record->rowClass !== App\dao\AbstractDao::TOTAL}
        <a href="{plink :month $record->year, $record->month}">{$$recordVariable|getValue:$columnName:FALSE}</a>
    {else}
        {$record->$columnName}
    {/if}
{/define}

@uestla
Copy link
Owner

uestla commented Feb 16, 2021

Since the $record variable is of any type of your choosing, I don't consider your approach "hacky". Maybe a bit verbose, but that's another issue :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants