YII2在gridview标题中添加colspan
如何在gridview的标题中添加YII2在gridview标题中添加colspan,gridview,yii2,yii-widgets,Gridview,Yii2,Yii Widgets,如何在gridview的标题中添加colspan 通常标题看起来像这样 <table class="table"> <thead> <tr> <th>Header1</th> <th>Header2</th> <th>Header3</th>
colspan
通常标题看起来像这样
<table class="table">
<thead>
<tr>
<th>Header1</th>
<th>Header2</th>
<th>Header3</th>
<th>Header4</th>
<th>HeaderA1</th>
<th>HeaderA2</th>
<th>HeaderA3</th>
<th>HeaderB1</th>
<th>HeaderB2</th>
<th>HeaderB3</th>
</tr>
</thead>
<tbody>
<tr>
<td>body1</td>
<td>body2</td>
<td>body3</td>
<td>body4</td>
<td>body5</td>
<td>body6</td>
<td>body7</td>
<td>body8</td>
<td>body9</td>
<td>body10</td>
</tr>
</tbody>
</table>
<table class="table">
<thead>
<tr>
<th rowspan=2>Header1</th>
<th rowspan=2>Header2</th>
<th rowspan=2>Header3</th>
<th rowspan=2>Header4</th>
<th colspan=3>Header A</th>
<th colspan=3>Header B</th>
</tr>
<tr>
<th>A1</th>
<th>A2</th>
<th>A3</th>
<th>B1</th>
<th>B2</th>
<th>B3</th>
</tr>
</thead>
<tbody>
<tr>
<td>body1</td>
<td>body2</td>
<td>body3</td>
<td>body4</td>
<td>body5</td>
<td>body6</td>
<td>body7</td>
<td>body8</td>
<td>body9</td>
<td>body10</td>
</tr>
</tbody>
</table>
校长1
校长2
校长3
校长4
校长1
校长2
校长3
校长1
校长二
校长3
车身1
车身2
车身3
车身4
车身5
车身6
车身7
车身8
车身9
车身10
我想让它看起来像这样
<table class="table">
<thead>
<tr>
<th>Header1</th>
<th>Header2</th>
<th>Header3</th>
<th>Header4</th>
<th>HeaderA1</th>
<th>HeaderA2</th>
<th>HeaderA3</th>
<th>HeaderB1</th>
<th>HeaderB2</th>
<th>HeaderB3</th>
</tr>
</thead>
<tbody>
<tr>
<td>body1</td>
<td>body2</td>
<td>body3</td>
<td>body4</td>
<td>body5</td>
<td>body6</td>
<td>body7</td>
<td>body8</td>
<td>body9</td>
<td>body10</td>
</tr>
</tbody>
</table>
<table class="table">
<thead>
<tr>
<th rowspan=2>Header1</th>
<th rowspan=2>Header2</th>
<th rowspan=2>Header3</th>
<th rowspan=2>Header4</th>
<th colspan=3>Header A</th>
<th colspan=3>Header B</th>
</tr>
<tr>
<th>A1</th>
<th>A2</th>
<th>A3</th>
<th>B1</th>
<th>B2</th>
<th>B3</th>
</tr>
</thead>
<tbody>
<tr>
<td>body1</td>
<td>body2</td>
<td>body3</td>
<td>body4</td>
<td>body5</td>
<td>body6</td>
<td>body7</td>
<td>body8</td>
<td>body9</td>
<td>body10</td>
</tr>
</tbody>
</table>
校长1
校长2
校长3
校长4
标题A
标题B
A1
A2
A3
地下一层
地下二层
地下三层
车身1
车身2
车身3
车身4
车身5
车身6
车身7
车身8
车身9
车身10
如果不扩展和重写网格视图小部件,这是不可能的。
看一看。如果查看,您可以看到它具有您需要的功能 要在表格标题中添加
colspan
,应将属性colspan
插入列的headerOptions
:
'headerOptions' => [
'colspan' => '2',
]
对于下一列,应使用以下内容隐藏其标题:
'headerOptions' => [
'style' => 'display: none;',
]