Class yii\grid\Column
Column 是所有 yii\grid\GridView 列类的基类。
有关 Column 的更多细节和用法,请参阅 guide article on data widgets。
公共属性
| 属性 | 类型 | 描述 | 被定义在 |
|---|---|---|---|
| $content | callable | 这是用于生成每个单元格内容的回调函数。
函数的写法如下:function ($model, $key, $index, $column)。
其中,$model,$key 和 $index 表示当前渲染行的模型,键和索引,
$column 是对 yii\grid\Column 对象的引用。 |
yii\grid\Column |
| $contentOptions | array|Closure | 数据单元标签的 HTML 属性。
这可以是属性数组或返回此类数组的匿名函数(Closure)。
函数的写法应该如下:function ($model, $key, $index, $column)。
其中,$model,$key 和 $index 表示当前渲染行的模型、键和索引,
$column 是对 yii\grid\Column 对象的引用。
函数可用于根据该行中的数据将不同的属性分配给不同的行。 |
yii\grid\Column |
| $filterOptions | array | 筛选单元格标签的 HTML 属性。 | yii\grid\Column |
| $footer | string | 页脚单元格内容。注意,它不是 HTML 编码的。 | yii\grid\Column |
| $footerOptions | array | The 页脚单元格标签的 HTML 属性。 | yii\grid\Column |
| $grid | yii\grid\GridView | 拥有此列的网格视图对象。 | yii\grid\Column |
| $header | string | 标题单元格内容。注意,它不是 HTML 编码的。 | yii\grid\Column |
| $headerOptions | array | 标题单元格标签的 HTML 属性。 | yii\grid\Column |
| $options | array | 列组标签的 HTML 属性。 | yii\grid\Column |
| $visible | boolean | 列是否可见。默认为 true。 | yii\grid\Column |
公共方法
| 方法 | 描述 | 被定义在 |
|---|---|---|
| __call() | Calls the named method which is not a class method. | yii\base\BaseObject |
| __construct() | Constructor. | yii\base\BaseObject |
| __get() | Returns the value of an object property. | yii\base\BaseObject |
| __isset() | Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
| __set() | Sets value of an object property. | yii\base\BaseObject |
| __unset() | Sets an object property to null. | yii\base\BaseObject |
| canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\BaseObject |
| canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\BaseObject |
| className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
| hasMethod() | Returns a value indicating whether a method is defined. | yii\base\BaseObject |
| hasProperty() | Returns a value indicating whether a property is defined. | yii\base\BaseObject |
| init() | Initializes the object. | yii\base\BaseObject |
| renderDataCell() | 渲染数据单元格。 | yii\grid\Column |
| renderFilterCell() | Renders the filter cell. | yii\grid\Column |
| renderFooterCell() | 渲染标题单元格。 | yii\grid\Column |
| renderHeaderCell() | Renders the header cell. | yii\grid\Column |
受保护的方法
| 方法 | 描述 | 被定义在 |
|---|---|---|
| getHeaderCellLabel() | 返回标题单元格标签。 可以重写此方法以自定义标题单元格的标签。 | yii\grid\Column |
| renderDataCellContent() | 渲染数据单元格内容。 | yii\grid\Column |
| renderFilterCellContent() | 渲染过滤单元格内容。 默认实现只是渲染一个空格。 可以重写此方法以自定义过滤器单元的渲染(如果有)。 | yii\grid\Column |
| renderFooterCellContent() | 渲染页脚单元格内容。 默认实现只是渲染 $footer。 可以重写此方法以自定义页脚单元格的渲染。 | yii\grid\Column |
| renderHeaderCellContent() | 渲染过滤单元格。 默认实现只是渲染 $header。 可以重写此方法以自定义标题单元格的渲染。 | yii\grid\Column |
属性详情
这是用于生成每个单元格内容的回调函数。
函数的写法如下:function ($model, $key, $index, $column)。
其中,$model,$key 和 $index 表示当前渲染行的模型,键和索引,
$column 是对 yii\grid\Column 对象的引用。
数据单元标签的 HTML 属性。
这可以是属性数组或返回此类数组的匿名函数(Closure)。
函数的写法应该如下:function ($model, $key, $index, $column)。
其中,$model,$key 和 $index 表示当前渲染行的模型、键和索引,
$column 是对 yii\grid\Column 对象的引用。
函数可用于根据该行中的数据将不同的属性分配给不同的行。
参见 yii\helpers\Html::renderTagAttributes() 有关如何渲染属性的详细信息。.
筛选单元格标签的 HTML 属性。
参见 yii\helpers\Html::renderTagAttributes() 有关如何渲染属性的详细信息。.
页脚单元格内容。注意,它不是 HTML 编码的。
The 页脚单元格标签的 HTML 属性。
参见 yii\helpers\Html::renderTagAttributes() 有关如何渲染属性的详细信息。.
拥有此列的网格视图对象。
标题单元格内容。注意,它不是 HTML 编码的。
标题单元格标签的 HTML 属性。
参见 yii\helpers\Html::renderTagAttributes() 有关如何渲染属性的详细信息。.
列组标签的 HTML 属性。
参见 yii\helpers\Html::renderTagAttributes() 有关如何渲染属性的详细信息。.
列是否可见。默认为 true。
方法详情
返回标题单元格标签。 可以重写此方法以自定义标题单元格的标签。
| protected string getHeaderCellLabel() | ||
| return | string | Label |
|---|---|---|
渲染数据单元格。
| public string renderDataCell($model, $key, $index) | ||
| $model | mixed | 数据模型 |
| $key | mixed | 与数据模型相关的键 |
| $index | integer | 由 yii\grid\GridView::$dataProvider 返回的模型数组中的数据模型的从零开始的索引。 |
| return | string | 渲染结果 |
|---|---|---|
渲染数据单元格内容。
| protected string renderDataCellContent($model, $key, $index) | ||
| $model | mixed | 数据模型 |
| $key | mixed | 与数据模型相关的键 |
| $index | integer | 由 yii\grid\GridView::$dataProvider 返回的模型数组中的数据模型的从零开始的索引。 |
| return | string | 渲染结果 |
|---|---|---|
Renders the filter cell.
| public void renderFilterCell() |
渲染过滤单元格内容。 默认实现只是渲染一个空格。 可以重写此方法以自定义过滤器单元的渲染(如果有)。
| protected string renderFilterCellContent() | ||
| return | string | 渲染结果 |
|---|---|---|
渲染标题单元格。
| public void renderFooterCell() |
渲染页脚单元格内容。 默认实现只是渲染 $footer。 可以重写此方法以自定义页脚单元格的渲染。
| protected string renderFooterCellContent() | ||
| return | string | 渲染结果 |
|---|---|---|
Renders the header cell.
| public void renderHeaderCell() |
渲染过滤单元格。 默认实现只是渲染 $header。 可以重写此方法以自定义标题单元格的渲染。
| protected string renderHeaderCellContent() | ||
| return | string | 渲染结果 |
|---|---|---|