Skip to content

Commit

Permalink
Add sort dir key
Browse files Browse the repository at this point in the history
  • Loading branch information
iranianpep committed Sep 21, 2016
1 parent dfe2688 commit 1b85cb6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 23 additions & 1 deletion src/PhpTableGenerator/HeadCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class HeadCell extends Cell
*/
private $sortDir;

/**
* @var
*/
private $sortDirKey;

public function __construct($title = null, $alias = null, $content = null, $htmlspecialchars = false)
{
if ($title !== null) {
Expand Down Expand Up @@ -227,6 +232,22 @@ public function getNewSortDir()
return ($alias === $sortBy && $sortDir === 'asc') ? 'desc' : 'asc';
}

/**
* @return string
*/
public function getSortDirKey()
{
return $this->sortDirKey;
}

/**
* @param string $sortDirKey
*/
public function setSortDirKey($sortDirKey)
{
$this->sortDirKey = $sortDirKey;
}

/**
* @return string
* @throws \Exception
Expand Down Expand Up @@ -257,7 +278,8 @@ public function getContent()
$newSortDir = $this->getNewSortDir();

$sortFunction = $config->getConfig('sorterJSFunction');
$sortDirKey = $this->getSortDirKey();

return "{$checkboxHtml} <a style='cursor: pointer;' onclick='{$sortFunction}(\"{$sortBy}\", \"{$alias}\", \"{$newSortDir}\");'>{$title}</a>";
return "{$checkboxHtml} <a style='cursor: pointer;' onclick='{$sortFunction}(\"{$sortBy}\", \"{$alias}\", \"{$sortDirKey}\", \"{$newSortDir}\");'>{$title}</a>";
}
}

0 comments on commit 1b85cb6

Please sign in to comment.