@@ -59,6 +59,11 @@ class Builder
59
59
*/
60
60
protected $ tableAttributes = ['class ' => 'table ' , 'id ' => 'dataTableBuilder ' ];
61
61
62
+ /**
63
+ * @var array
64
+ */
65
+ protected $ allowedHeaderAttributes = ['class ' , 'id ' , 'width ' , 'style ' , 'data-class ' , 'data-hide ' ];
66
+
62
67
/**
63
68
* @var string
64
69
*/
@@ -563,9 +568,10 @@ public function ajax($attributes)
563
568
* @param bool $drawFooter
564
569
* @return string
565
570
*/
566
- public function table (array $ attributes = [], $ drawFooter = false )
571
+ public function table (array $ attributes = [], $ drawFooter = false , array $ headerAttributes = [] )
567
572
{
568
573
$ this ->tableAttributes = array_merge ($ this ->tableAttributes , $ attributes );
574
+ $ this ->allowedHeaderAttributes = array_merge ($ this ->allowedHeaderAttributes , $ headerAttributes );
569
575
570
576
$ th = $ this ->compileTableHeaders ();
571
577
$ htmlAttr = $ this ->html ->attributes ($ this ->tableAttributes );
@@ -591,7 +597,7 @@ private function compileTableHeaders()
591
597
$ th = [];
592
598
foreach ($ this ->collection ->toArray () as $ row ) {
593
599
$ thAttr = $ this ->html ->attributes (
594
- array_only ($ row , [ ' class ' , ' id ' , ' width ' , ' style ' , ' data-class ' , ' data-hide ' ] )
600
+ array_only ($ row , $ this -> allowedHeaderAttributes )
595
601
);
596
602
$ th [] = '<th ' . $ thAttr . '> ' . $ row ['title ' ] . '</th> ' ;
597
603
}
0 commit comments