Skip to content

Commit

Permalink
Fixed sorting bug, closes #359
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Janda committed Sep 19, 2016
1 parent 132ca91 commit 4eddaf6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/Column/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/datagrid.latte
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
{include #$col_header, column => $column}
{else}
{if $column->isSortable()}
<a n:class="$column->isSortedBy() ? 'sort' : '', 'ajax'" n:href="sort!, sort => $column->getSortNext()" id="datagrid-sort-{$key}">
<a n:class="$column->isSortedBy() ? 'sort' : '', 'ajax'" {if $column->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()}
Expand Down

0 comments on commit 4eddaf6

Please sign in to comment.