Combination headers

The Grid::combine method makes it easy to combine any two or more fields into a first-level table header.

Combination headers - 图1

Example

  1. protected function grid()
  2. {
  3. return Grid::make(new Report(), function (Grid $grid) {
  4. // The first parameter is the primary table header field name, the second field is the secondary table header field name, the secondary table header field is set to at least two
  5. $grid->combine('avgCost', ['avgMonthCost', 'avgQuarterCost', 'avgYearCost']);
  6. $grid->combine('avgVist', ['avgMonthVist', 'avgQuarterVist', 'avgYearVist']);
  7. // Set the style
  8. $grid->combine('top', ['topCost', 'topVist', 'topIncr'])->style('color:#1867c0');
  9. $grid->column('content')->limit(50);
  10. $grid->column('cost')->sortable();
  11. $grid->column('avgMonthCost');
  12. $grid->column('avgQuarterCost')->setHeaderAttributes(['style' => 'color:#5b69bc']);
  13. $grid->column('avgYearCost');
  14. $grid->column('avgMonthVist');
  15. $grid->column('avgQuarterVist');
  16. $grid->column('avgYearVist');
  17. $grid->column('incrs');
  18. $grid->column('avgVists');
  19. $grid->column('topCost');
  20. $grid->column('topVist');
  21. $grid->column('topIncr');
  22. $grid->column('date')->sortable();
  23. });
  24. }