From 4eddaf61012e489258d039801e2c344e5cb8d37a Mon Sep 17 00:00:00 2001 From: Pavel Janda Date: Mon, 19 Sep 2016 13:22:17 +0200 Subject: [PATCH] Fixed sorting bug, closes #359 --- src/Column/Column.php | 11 +++++++++++ src/DataGrid.php | 5 +++++ src/templates/datagrid.latte | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Column/Column.php b/src/Column/Column.php index 2664d3c2..72d8213f 100644 --- a/src/Column/Column.php +++ b/src/Column/Column.php @@ -468,6 +468,17 @@ public function getSortNext() } + /** + * @return bool + */ + public function hasSortNext() + { + foreach ($this->getSortNext() as $key => $order) { + return $order !== FALSE; + } + } + + /** * Is sorting ascending? * @return bool diff --git a/src/DataGrid.php b/src/DataGrid.php index e882f144..d6f3d1f2 100644 --- a/src/DataGrid.php +++ b/src/DataGrid.php @@ -713,6 +713,11 @@ public function getSortableHandler() } + /** + * @param array $sort + * @param callable|NULL $sort_callback + * @return void + */ protected function createSorting(array $sort, $sort_callback) { foreach ($sort as $key => $order) { diff --git a/src/templates/datagrid.latte b/src/templates/datagrid.latte index 59f78801..89b35f77 100644 --- a/src/templates/datagrid.latte +++ b/src/templates/datagrid.latte @@ -138,7 +138,7 @@ {include #$col_header, column => $column} {else} {if $column->isSortable()} - + hasSortNext()}href="{link sort!, sort => $column->getSortNext()}"{else}href="{link sort!, sort => NULL}"{/if} id="datagrid-sort-{$key}"> {include #column-header, column => $column} {if $column->isSortedBy()}