Skip to content

Commit

Permalink
added support for custom cell rendering in inline edit mode [closes #31]
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Feb 17, 2017
1 parent 5e03abf commit 238712a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion doc/default.texy
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ Here is list of suitable blocks for redefinition:
| `row` | row rendering, for `<tr>` tag decoration | `$rowId`, `$row`
| `col-filter-*` | custom filter cell rendering | `$form` - filter's `Nette\Form\IContainer`, `$column` - Column instance
| `col-filter` | global custom filter cell rendering; this block has lower priority than `col-filter-*` | same variables as for `col-filter-*`
| `col-*` | custom cell rendering; **only this block must include ''<td>'' tags**; | `$row`, `$cell`
| `col-*` | custom cell rendering; **this block must include ''<td>'' tag**; | `$row`, `$cell`
| `cell-*` | custom cell contents rendering | `$row`, `$cell`
| `cell-edit-*` | custom inline edit cell rendering | `$row`, `$column`, `$form`
| `pagination` | custom pagination | `$control`, `$paginator` - Nette\Utils\Paginator instance
| `empty-result` | custom implementation of table row when no results were found

Expand Down
18 changes: 11 additions & 7 deletions src/Datagrid.blocks.latte
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,18 @@
{/ifset}
{foreach $columns as $column}
{var $cell = $control->getter($row, $column->name, FALSE)}
{if $editRow && $column->name != $rowPrimaryKey && isset($form['edit'][$column->name])}
{if $editRow && $column->name != $rowPrimaryKey && (isset($form['edit'][$column->name]) || isset($this->blockQueue["cell-edit-{$column->name}"]))}
<td class="grid-col-{$column->name}">
{formContainer edit}
{input $column->name}
{if $form[edit][$column->name]->hasErrors()}
<p class="error" n:foreach="$form[edit][$column->name]->getErrors() as $error">{$error}</p>
{/if}
{/formContainer}
{ifset #cell-edit-$column->name}
{include #"cell-edit-{$column->name}" form => $form, column => $column, row => $row}
{else}
{formContainer edit}
{input $column->name}
{if $form[edit][$column->name]->hasErrors()}
<p class="error" n:foreach="$form[edit][$column->name]->getErrors() as $error">{$error}</p>
{/if}
{/formContainer}
{/ifset}
</td>
{else}
{ifset #col-$column->name}
Expand Down

0 comments on commit 238712a

Please sign in to comment.