As mentioned in the previous paragraph, the columns
property of the GridView widget is mainly filled with strings.
When we need to apply a specific format, such as currency or date/time, we can append this specification to the column name with a colon and the type used for formatting, as currency
or datetime
.
But the most general form of a GridView column is an object of the yii\grid\Column
class, derived by the yii\grid\DataColumn
class.
A GridView column extended by the yii\grid\Column
class is rendered using an array with the following keys:
[ // can be omitted, as it is the default 'class' => 'yii\grid\DataColumn', 'attribute', // name of model attribute 'format', // format use to display data 'header', // header of column 'footer', // footer of column 'visible', // flag to set visibility 'content' // callback to print data ],