Бортовой журнал Ктулху

Override the GridView table view in Yii2

How to change table view in Yii2 component GridView.

First of all, you should override standard files. For this you need to create in /%yii dir%/components your own "GridView", en example "MyGridView".



File may contain same methods as original file that was extended.

If you need to change behavior of some method, you should create it in your GridView with same name.

namespace app\components;
use yii\grid\GridView;
class MyGridView extends GridView
public function renderTableHeader()
 $header = parent::renderTableHeader();
 return str_replace('</thead>','',str_replace('<thead>','',$header));


For running MyGridView change yii\grid\GridView::widget([...]) to app\components\MyGridView([...])