I am using gridview to list all my data. my table looks like this.
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'firstName',
'lastName',
'startDate',
'hiredDate'
],
]) ?>
which renders a table like this.

how can i add another header for grouping NAME and DATE so that it will look like this. like rowspan in pure HTML.

Use https://github.com/kartik-v/yii2-grid extension
<?= GridView::widget([
'beforeHeader' => [
[
'columns' => [
['content' => 'Name', 'options' => ['colspan' => 2, 'class' => 'text-center warning']],
['content' => 'Date', 'options' => ['colspan' => 2, 'class' => 'text-center warning']],
],
]
],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With