$columns public property
Grid column configuration. Each array element represents the configuration for one particular grid column. For example,
[ ['class' => SerialColumn::className()], [ 'class' => DataColumn::className(), // this line is optional 'attribute' => 'name', 'format' => 'text', 'label' => 'Name', ], ['class' => CheckboxColumn::className()], ]
If a column is of class yii\grid\DataColumn, the "class" element can be omitted.
As a shortcut format, a string may be used to specify the configuration of a data column which only contains attribute, format, and/or label options: "attribute:format:label"
. For example, the above "name" column can also be specified as: "name:text:Name"
. Both "format" and "label" are optional. They will take default values if absent.
Using the shortcut format the configuration for columns in simple cases would look like this:
[ 'id', 'amount:currency:Total Amount', 'created_at:datetime', ]
When using a $dataProvider with active records, you can also display values from related records, e.g. the name
attribute of the author
relation:
// shortcut syntax 'author.name', // full syntax [ 'attribute' => 'author.name', // ... ]
Please login to continue.