Skip to content

Instantly share code, notes, and snippets.

@Kurtas
Created August 12, 2012 16:37
Show Gist options
  • Save Kurtas/3332736 to your computer and use it in GitHub Desktop.
Save Kurtas/3332736 to your computer and use it in GitHub Desktop.
NiftyGrid - eng temlapte
{snippet}
{if !$control->isSubGrid}
{$control['gridForm']->render('begin')}
{/if}
<div n:foreach="$flashes as $flash" class="flash {$flash->type}">{$flash->message}</div>
<table n:attr="style => $control->width ? 'width: '.$control->width.';'" class="grid">
<thead>
<tr class="grid-panel">
<th colspan="{$colsCount}">
<div class="grid-upper-panel">
<a n:href="this" class="grid-current-link" title="{_}Url for this page{/_}"></a>
<div class="grid-results">
{_}Total{/_} {$results} {_($results == 1) ? "record" : (($results >= 2 && $results <= 4) ? "records" : "records")}{if $paginate} {if (boolean)$results}({_}Displayed{/_} {$viewedFrom} to {$viewedTo}){/if}{/if}
</div>
</div>
</th>
</tr>
<tr>
<th n:if="$control->hasActionForm()" style="text-align:center; width: 16px;" class="grid-head-column"><input type="checkbox" class="grid-select-all" title="{_}Mark / unmark all records{/_}"></th>
<th n:foreach="$subGrids as $subGrid" style="width: 26px;" class="grid-head-column"></th>
<th n:foreach="$columns as $column" n:attr="style => $column->width ? 'width: '.$column->width.';'" class="grid-head-column">{if $control->hasEnabledSorting() && $column->isSortable()}{var $order = ($control->order == $column->name.' ASC') ? " DESC" : " ASC"}<a n:href="this, 'order' => $column->name.$order" class="grid-ajax" title="{_}Reverse sorting{/_}">{_$column->label}</a>{else}{_$column->label}{/if}
<div class="grid-order" n:if="$column->isSortable() && $control->hasEnabledSorting()">
<a n:href="this, 'order' => $column->name.' ASC'" n:class="grid-ajax, grid-order-up ,($control->order && ($control->order == $column->name.' ASC')) ? grid-order-active-up" title="{_}Sort ascending{/_}"></a>
<a n:href="this, 'order' => $column->name.' DESC'" n:class="grid-ajax, grid-order-down ,($control->order && ($control->order == $column->name.' DESC')) ? grid-order-active-down" title="{_}Sort descending{/_}"></a>
</div>
</th>
<th n:if="$control->hasButtons() || $control->hasFilterForm()" class="grid-head-column">{_}Actions{/_}</th>
</tr>
<tr n:if="$control->hasFilterForm()">
<th n:if="$control->hasActionForm()" class="grid-filter-form"></th>
<th n:foreach="$subGrids as $subGrid" class="grid-filter-form"></th>
<th n:foreach="$columns as $column" n:attr="class => array(grid-filter-form, $control->isSpecificFilterActive($column->name) ? grid-filter-form-active)">
{if $column->hasFilter()}
{$control['gridForm'][$control->name]['filter'][$column->name]->getControl()}
{/if}
</th>
<th class="grid-filter-form">{$control['gridForm'][$control->name]['filter']['send']->getControl()}<a n:if="$control->hasActiveFilter()" n:href="this, filter => NULL, paginator-page => NULL" title="{_}Cancel filtering{/_}" class="grid-filter-reset grid-ajax"></a></th>
</tr>
</thead>
<tbody>
{if count($rows)}
{foreach $rows as $row}
<tr n:attr="class => $iterator->isOdd() ? grid-row-odd : grid-row-even">
<td n:if="$control->hasActionForm()" n:attr="class => array(grid-row-cell, grid-action-checkbox, $control->isEditable() && $control->activeRowForm == $row[$primaryKey] ? 'grid-edited-cell')">{$control->assignCheckboxToRow($row[$primaryKey])}</td>
<td n:foreach="$subGrids as $subgrid" n:attr="class => array(grid-row-cell, $control->isEditable() && $control->activeRowForm == $row[$primaryKey] ? 'grid-edited-cell')">
{control $subgrid $row}
</td>
<td n:foreach="$columns as $column" n:attr="class => array(grid-row-cell, grid-data-cell, $control->isEditable() && $control->activeRowForm == $row[$primaryKey] ? 'grid-edited-cell'), style => $column->hasCellRenderer() ? $column->getCellRenderer($row)">
{if $control->isEditable() && $column->editable && $control->activeRowForm == $row[$primaryKey]}
{$control['gridForm'][$control->name]['rowForm'][$column->name]->getControl()}
{else}
{$column->prepareValue($row)}
{/if}
</td>
<td n:if="$control->hasButtons() || $control->hasFilterForm()" n:attr="class => array(grid-row-cell, $control->isEditable() && $control->activeRowForm == $row[$primaryKey] ? 'grid-edited-cell')">
{if $control->activeRowForm == $row[$primaryKey] && $control->isEditable()}
{$control['gridForm'][$control->name]['rowForm']['send']->getControl()}
<a class="grid-rowForm-cancel grid-ajax" n:href="this" title="{_}Cancel editing{/_}"></a>
{$control['gridForm'][$control->name]['rowForm'][$primaryKey]->getControl()}
{else}
{foreach $buttons as $button}
{control $button $row}
{/foreach}
{/if}
</td>
</tr>
<tr n:if="$control->hasActiveSubGrid() && $control->activeSubGridId == $row[$primaryKey]" class="grid-subgrid-row" align="center">
<td colspan="{$colsCount}" n:attr="style => $control['subGrids-'.$control->activeSubGridName]->hasCellStyle() ? $control['subGrids-'.$control->activeSubGridName]->getCellStyle().'border-bottom:1px solid #f2f2f2;'">
{control $control['subGrid'.$control->activeSubGridName]}
</td>
</tr>
{/foreach}
{else}
<tr>
<td class="grid-row-cell" style="background-color:#FFF; font-size:16px;" colspan="{$colsCount}">{_}No records{/_}</td>
</tr>
{/if}
</tbody>
<tfoot>
<tr>
<td colspan="{$colsCount}" class="grid-bottom">
<span n:if="$control->hasActionForm()" class="grid-action-box">
{$control['gridForm'][$control->name]['action']['action_name']->label}
{$control['gridForm'][$control->name]['action']['action_name']->getControl()}
{$control['gridForm'][$control->name]['action']['send']->getControl()}
</span>
<span n:if="$paginate" class="grid-perPage">
{$control['gridForm'][$control->name]['perPage']['perPage']->label}
{$control['gridForm'][$control->name]['perPage']['perPage']->getControl()}
{$control['gridForm'][$control->name]['perPage']['send']->getControl()}
</span>
</td>
</tr>
<tr n:if="$paginate" class="grid-panel">
<td colspan="{$colsCount}">
{control paginator}
</td>
</tr>
</tfoot>
</table>
{if !$control->isSubGrid}
{$control['gridForm']->render('end')}
{/if}
{/snippet}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment