contributte/datagrid

TreeView does not update rows after AJAX (filter, etc.)

nothrem opened this issue · 0 comments

When DataGrid is switched into TreeView it renders items by separate template (/src/templates/datagrid_tree.latte). This template overwrites the base template /src/templates/datagrid.latte.

But the treeview template does not define all snippets from the datagrid template - specifically it's missing snippet tbody (probably because the TreeView does not actuallly use table).

As a result, when grid requests the whole body to be refreshed (e.g. after changing filters), the grid receives the snippet tbody but does not know where to update it in the DOM. Thus the new list of rows send by AJAX is ignored and old rows remains displayed.

I have found possible solution by replacing the base snippet table by the more specific tbody in the datagrid_tree.latte, but I don't know if the table snippet is used for something and if it would break something else.

current datagrid_tree.latte

<div class="datagrid-tree-item-children datagrid-tree" n:snippet="table" ...

suggested fix for datagrid_tree.latte

<div class="datagrid-tree-item-children datagrid-tree" n:snippet="tbody" ...

Workaround:

$grid->setTemplate('/path/to/your/fixed_copy_of_datagrid_tree.latte');