Commit eeb4e29d by Carsten Brandt

improve gridview phpdoc

parent b6be7111
......@@ -29,10 +29,10 @@ use yii\helpers\Html;
* Users may click on the checkboxes to select rows of the grid. The selected rows may be
* obtained by calling the following JavaScript code:
*
* ~~~
* ```javascript
* var keys = $('#grid').yiiGridView('getSelectedRows');
* // keys is an array consisting of the keys associated with the selected rows
* ~~~
* ```
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
......@@ -46,6 +46,19 @@ class CheckboxColumn extends Column
/**
* @var array|\Closure the HTML attributes for checkboxes. This can either be an array of
* attributes or an anonymous function ([[Closure]]) that returns such an array.
* The signature of the function should be the following: `function ($model, $key, $index, $column)`.
* Where `$model`, `$key`, and `$index` refer to the model, key and index of the row currently being rendered
* and `$column` is a reference to the [[CheckboxColumn]] object.
* A function may be used to assign different attributes to different rows based on the data in that row.
* Specifically if you want to set a different value for the checkbox
* you can use this option in the following way (in this example using the `name` attribute of the model):
*
* ```php
* 'checkboxOptions' => function($model, $key, $index, $column) {
* return ['value' => $model->name];
* }
* ```
*
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $checkboxOptions = [];
......
......@@ -34,6 +34,8 @@ class Column extends Object
/**
* @var callable This is a callable that will be used to generated the content of each cell.
* The signature of the function should be the following: `function ($model, $key, $index, $column)`.
* Where `$model`, `$key`, and `$index` refer to the model, key and index of the row currently being rendered
* and `$column` is a reference to the [[Column]] object.
*/
public $content;
/**
......@@ -54,6 +56,8 @@ class Column extends Object
* @var array|\Closure the HTML attributes for the data cell tag. This can either be an array of
* attributes or an anonymous function ([[Closure]]) that returns such an array.
* The signature of the function should be the following: `function ($model, $key, $index, $column)`.
* Where `$model`, `$key`, and `$index` refer to the model, key and index of the row currently being rendered
* and `$column` is a reference to the [[Column]] object.
* A function may be used to assign different attributes to different rows based on the data in that row.
*
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
......
......@@ -56,13 +56,18 @@ class DataColumn extends Column
*/
public $encodeLabel = true;
/**
* @var string|\Closure an anonymous function that returns the value to be displayed for every data model.
* The signature of this function is `function ($model, $key, $index, $column)`.
* If this is not set, `$model[$attribute]` will be used to obtain the value.
* @var string|\Closure an anonymous function or a string that is used to determine the value to display in the current column.
*
* If this is an anonymous function, it will be called for each row and the return value will be used as the value to
* display for every data model. The signature of this function should be: `function ($model, $key, $index, $column)`.
* Where `$model`, `$key`, and `$index` refer to the model, key and index of the row currently being rendered
* and `$column` is a reference to the [[DataColumn]] object.
*
* You may also set this property to a string representing the attribute name to be displayed in this column.
* This can be used when the attribute to be displayed is different from the [[attribute]] that is used for
* sorting and filtering.
*
* If this is not set, `$model[$attribute]` will be used to obtain the value, where `$attribute` is the value of [[attribute]].
*/
public $value;
/**
......
......@@ -27,6 +27,9 @@ namespace yii\grid;
*/
class SerialColumn extends Column
{
/**
* @inheritdoc
*/
public $header = '#';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment