Skip to content

Commit

Permalink
Filtrovani,razeni VS (#936)
Browse files Browse the repository at this point in the history
* Použití atributu column pro sloupce místo Renderer

* Použití addColumnLink pro buňky s odkazem

* Správná filtrace řetězených sloupců

zatím jen VS

* Řazení řetězených sloupců

zatím jen VS

Co-authored-by: bojovyletoun <>
  • Loading branch information
bojovyletoun authored and jan-stanek committed Apr 5, 2023
1 parent e46b66c commit 30f9a7d
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions app/AdminModule/Components/GroupsGridControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
use App\Services\ExcelExportService;
use App\Utils\Helpers;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\QueryBuilder;
use Exception;
use Nette\Application\AbortException;
use Nette\Application\UI\Control;
use Nette\Http\Session;
use Nette\Http\SessionSection;
use Nette\Localization\Translator;
use Nette\Utils\Html;
use Throwable;
use Ublaboo\DataGrid\DataGrid;
use Ublaboo\DataGrid\Exception\DataGridColumnStatusException;
Expand Down Expand Up @@ -85,16 +85,23 @@ public function createComponentPatrolsGrid(string $name): DataGrid
->setSortable()
->setFilterText();

$grid->addColumnText('variableSymbol', 'VS ')->setSortable() // je stejný jako název skupiny
->setRenderer(static fn ($t) => $t->getVariableSymbolText())
->setFilterText();

$grid->addColumnText('leader', 'Vedoucí')->setSortable()
->setRenderer(function (Troop $t) {
$leader = $t->getLeader();

return Html::el('a')->setAttribute('href', $this->getPresenter()->link('detail', $leader->getId()))->setText($leader->getDisplayName());
})
$grid->addColumnText('variableSymbol', 'VS ', 'variableSymbolText')
->setSortable()
->setSortableCallback(static function (QueryBuilder $qb, array $sort): void {
$sortRev = $sort['variableSymbolText'] === 'DESC' ? 'ASC' : 'DESC';
$qb->join('p.variableSymbol', 'VS')
->orderBy('VS.variableSymbol', $sortRev);
})
->setFilterText()
->setCondition(static function (QueryBuilder $qb, string $value): void {
// $qb->join('p.applications', 'uAVS')
$qb->join('p.variableSymbol', 'VS')
->andWhere('VS.variableSymbol LIKE :variableSymbol')
->setParameter(':variableSymbol', '%' . $value . '%');
});

$grid->addColumnLink('leader', 'Vedoucí', ':detail', 'leader.displayName', ['id' => 'leader.id'])->setSortable()
// return Html::el('a')->setAttribute('href', $this->getPresenter()->link('detail', $leader->getId()))->setText($leader->getDisplayName());
->setFilterText();

$grid->addColumnDateTime('applicationDate', 'Datum založení')
Expand Down

0 comments on commit 30f9a7d

Please sign in to comment.