Skip to content

Commit 1d487ad

Browse files
committed
configurable header attributes
1 parent b0d3abf commit 1d487ad

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Html/Builder.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class Builder
5959
*/
6060
protected $tableAttributes = ['class' => 'table', 'id' => 'dataTableBuilder'];
6161

62+
/**
63+
* @var array
64+
*/
65+
protected $allowedHeaderAttributes = ['class', 'id', 'width', 'style', 'data-class', 'data-hide'];
66+
6267
/**
6368
* @var string
6469
*/
@@ -563,9 +568,10 @@ public function ajax($attributes)
563568
* @param bool $drawFooter
564569
* @return string
565570
*/
566-
public function table(array $attributes = [], $drawFooter = false)
571+
public function table(array $attributes = [], $drawFooter = false, array $headerAttributes = [])
567572
{
568573
$this->tableAttributes = array_merge($this->tableAttributes, $attributes);
574+
$this->allowedHeaderAttributes = array_merge($this->allowedHeaderAttributes, $headerAttributes);
569575

570576
$th = $this->compileTableHeaders();
571577
$htmlAttr = $this->html->attributes($this->tableAttributes);
@@ -591,7 +597,7 @@ private function compileTableHeaders()
591597
$th = [];
592598
foreach ($this->collection->toArray() as $row) {
593599
$thAttr = $this->html->attributes(
594-
array_only($row, ['class', 'id', 'width', 'style', 'data-class', 'data-hide'])
600+
array_only($row, $this->allowedHeaderAttributes)
595601
);
596602
$th[] = '<th ' . $thAttr . '>' . $row['title'] . '</th>';
597603
}

0 commit comments

Comments
 (0)