组合表头
<h1>组合表头</h1>
<p>通过 <code>Grid::combine</code> 方法可以很方便的把任意两个以上的字段组合成一级表头</p>
<p><a href="<a href="http://103.39.211.179:8080/admin/reports"">http://103.39.211.179:8080/admin/reports"</a>; target="_blank">
<img style="box-shadow:0 1px 6px 1px rgba(0, 0, 0, 0.12)" width="100%" src="{{public}}/assets/img/screenshots/grid-combination.png">
</a></p>
<p>示例</p>
<pre><code class="language-php">protected function grid()
{
return Grid::make(new Report(), function (Grid $grid) {
// 第一个参数为一级表头字段名称,第二个字段为二级表头字段名称,二级表头字段最少设置两个
$grid-&gt;combine('avgCost', ['avgMonthCost', 'avgQuarterCost', 'avgYearCost']);
$grid-&gt;combine('avgVist', ['avgMonthVist', 'avgQuarterVist', 'avgYearVist']);
// 设置样式
$grid-&gt;combine('top', ['topCost', 'topVist', 'topIncr'])-&gt;style('color:#1867c0');
$grid-&gt;column('content')-&gt;limit(50);
$grid-&gt;column('cost')-&gt;sortable();
$grid-&gt;column('avgMonthCost');
$grid-&gt;column('avgQuarterCost')-&gt;setHeaderAttributes(['style' =&gt; 'color:#5b69bc']);
$grid-&gt;column('avgYearCost');
$grid-&gt;column('avgMonthVist');
$grid-&gt;column('avgQuarterVist');
$grid-&gt;column('avgYearVist');
$grid-&gt;column('incrs');
$grid-&gt;column('avgVists');
$grid-&gt;column('topCost');
$grid-&gt;column('topVist');
$grid-&gt;column('topIncr');
$grid-&gt;column('date')-&gt;sortable();
});
}</code></pre>