继承 | yii\grid\RadioButtonColumn » yii\grid\Column » yii\base\Object |
---|---|
可用自版本 | 2.0.11 |
RadioButtonColumn 在网格视图中显示一列单选按钮。
添加一个RadioButtonColumn网格yii\grid\GridView数据表格,将其添加到列配置如下:
'columns' => [
// ...
[
'class' => 'yii\grid\RadioButtonColumn',
'radioOptions' => function ($model) {
return [
'value' => $model['value'],
'checked' => $model['value'] == 2
];
}
],
]
公共属性
属性 | 类型 | 描述 | 定义在 |
---|---|---|---|
$name | string | 输入单选按钮输入字段的名称。 | yii\grid\RadioButtonColumn |
$radioOptions | array|Closure | HTML属性单选按钮。 | yii\grid\RadioButtonColumn |
公共方法
方法 | 描述 | 定义在 |
---|---|---|
init() | yii\grid\RadioButtonColumn |
受保护的方法
方法 | 描述 | 定义在 |
---|---|---|
renderDataCellContent() | yii\grid\RadioButtonColumn |
属性详情
$name public property
输入单选按钮输入字段的名称。
public string $name = 'radioButtonSelection'
$radioOptions public property
HTML属性单选按钮。这个属性可以是一个数组或一个匿名function (Closure)返回一个数组。
对于《function should be as胎function ($model, $key, $index, $column)
,争取column where $model
, $key
, and $index
rrefer model to The key,目前的境遇和index of The column和美元的新的管理本is a reference to The yii\grid\RadioButtonColumnobject.
一个函数可以用来将不同属性分配给不同的行基于这一行中的数据。特别是如果你想设置一个不同的单选按钮的值可以以以下方式使用这个选项(在本例中使用的名称属性模型):
'radioOptions' => function ($model, $key, $index, $column) {
return ['value' => $model->attribute];
}
参见 yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
public array|Closure $radioOptions = []
方法详情
init() public 方法
public void init ( ) | ||
throws | yii\base\InvalidConfigException | if $name is not set. |
---|
renderDataCellContent() protected 方法
protected void renderDataCellContent ( $model, $key, $index ) | ||
$model | ||
$key | ||
$index |