Allow list configs to add class to head row cell (#4207)

Credit to @bennothommo. Documented by https://github.com/octobercms/docs/pull/367
This commit is contained in:
Ben Thomson 2019-03-26 03:37:32 +08:00 committed by Luke Towers
parent cb24d817ad
commit 8c1106f027
2 changed files with 10 additions and 2 deletions

View File

@ -81,6 +81,11 @@ class ListColumn
*/
public $cssClass;
/**
* @var string Specify a CSS class to attach to the list header cell element.
*/
public $headCssClass;
/**
* @var string Specify a format or style for the column value, such as a Date.
*/
@ -138,6 +143,9 @@ class ListColumn
if (isset($config['cssClass'])) {
$this->cssClass = $config['cssClass'];
}
if (isset($config['headCssClass'])) {
$this->headCssClass = $config['headCssClass'];
}
if (isset($config['searchable'])) {
$this->searchable = $config['searchable'];
}

View File

@ -18,7 +18,7 @@
<?php if ($showSorting && $column->sortable): ?>
<th
<?php if ($column->width): ?>style="width: <?= $column->width ?>"<?php endif ?>
class="<?= $this->sortColumn==$column->columnName?'sort-'.$this->sortDirection.' active':'sort-desc' ?> list-cell-name-<?= $column->getName() ?> list-cell-type-<?= $column->type ?> <?= $column->getAlignClass() ?>"
class="<?= $this->sortColumn==$column->columnName?'sort-'.$this->sortDirection.' active':'sort-desc' ?> list-cell-name-<?= $column->getName() ?> list-cell-type-<?= $column->type ?> <?= $column->getAlignClass() ?> <?= $column->headCssClass ?>"
>
<a
href="javascript:;"
@ -31,7 +31,7 @@
<?php else: ?>
<th
<?php if ($column->width): ?>style="width: <?= $column->width ?>"<?php endif ?>
class="list-cell-name-<?= $column->getName() ?> list-cell-type-<?= $column->type ?> <?= $column->getAlignClass() ?>"
class="list-cell-name-<?= $column->getName() ?> list-cell-type-<?= $column->type ?> <?= $column->getAlignClass() ?> <?= $column->headCssClass ?>"
>
<span><?= $this->getHeaderValue($column) ?></span>
</th>