From 238712a205e474f45be4208fe05106a6dd2a2747 Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Fri, 17 Feb 2017 17:25:57 +0100 Subject: [PATCH] added support for custom cell rendering in inline edit mode [closes #31] --- doc/default.texy | 4 +++- src/Datagrid.blocks.latte | 18 +++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/doc/default.texy b/doc/default.texy index 6071e44..55c0834 100644 --- a/doc/default.texy +++ b/doc/default.texy @@ -94,7 +94,9 @@ Here is list of suitable blocks for redefinition: | `row` | row rendering, for `` 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 '''' tags**; | `$row`, `$cell` +| `col-*` | custom cell rendering; **this block must include '''' 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 diff --git a/src/Datagrid.blocks.latte b/src/Datagrid.blocks.latte index ea3df6c..bea393f 100644 --- a/src/Datagrid.blocks.latte +++ b/src/Datagrid.blocks.latte @@ -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}"]))} - {formContainer edit} - {input $column->name} - {if $form[edit][$column->name]->hasErrors()} -

{$error}

- {/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()} +

{$error}

+ {/if} + {/formContainer} + {/ifset} {else} {ifset #col-$column->name}