Own class to replace/ovewrite the yii\grid\Column vendor class

Hi everyone,

I would like to write own class to replace the Yii vendor class yii\grid\Column. The reason is that I don’t want to make my changes directly into the vendor module due to eventual update. Logically I think that I have to create a child class of that class and overwrite the methods I want to change. But My problem is that I can’t figure out where the yii\grid\Column class is been called. Fact is it’s being used when making a GridView::widget() but where is it triggered ?


You extend yii\grid\Column and use your class by adding

'class' => YourColumn::className()

in column configuration inside GridView.

Or you can map yii\grid\Column to be your class instead of original one. Instruction how to do this is here: http://www.yiiframework.com/doc-2.0/guide-concept-autoloading.html#class-map

Thanks for this.

It work with

'class' => YourColumn::className()

But somehow the Sorting is not active in my define column, and the column header is not longer active or clickable. With the default yii\grid\Column the sorting is active on every table header with the possibility to click on it to order the display by that db column field.

I am probably doing something wrong?

Looks like you don’t want to extend yii\grid\Column but rather yii\grid\DataColumn.

Indeed it is yii\grid\DataColumn,

Thanks a lot.