Yii 如何根据条件将对比信息放入CGridView列中?

Yii 如何根据条件将对比信息放入CGridView列中?,yii,cgridview,cbuttoncolumn,Yii,Cgridview,Cbuttoncolumn,我正在研究在Wii框架的CGridView小部件上显示/隐藏特定列数据 我有一个包含3个按钮的CButtonColumn。但是,在某些条件下,我希望为特定行显示不同的内容。 我有3个不同的条件来决定为特定行显示什么 以下说明了我要做的事情: | 1 | Title A | [hide][view][update] <-- if (condition == 'a') | 2 | Title B | [hide][view][update] <

我正在研究在Wii框架的
CGridView
小部件上显示/隐藏特定列数据

我有一个包含3个按钮的
CButtonColumn
。但是,在某些条件下,我希望为特定行显示不同的内容。 我有3个不同的条件来决定为特定行显示什么

以下说明了我要做的事情:

| 1 | Title A | [hide][view][update]            <-- if (condition == 'a')
| 2 | Title B | [hide][view][update]            <-- if (condition == 'a')
| 3 | Title C | display text or link or button  <-- if (condition == 'b')
| 4 | Title D | display alternative buttons     <-- if (condition == 'c')

希望我在这里有足够的意义

您应该使用
visible
按钮选项,但它应该是一个PHP表达式字符串,例如:

'visible'=> '$data->status == "done"',

使用您自己的类扩展CButtonColumn,然后您应该能够将此函数更改为渲染或隐藏按钮或进行任何更改所需的任何内容

/**
 * Renders a link button.
 * @param string $id the ID of the button
 * @param array $button the button configuration which may contain 'label', 'url', 'data-icon', 'imageUrl' and 'options' elements.
 * @param integer $row the row number (zero-based)
 * @param mixed $data the data object associated with the row
 */
protected function renderButton($id, $button, $row, $data)
有关该函数的更多详细信息

/**
 * Renders a link button.
 * @param string $id the ID of the button
 * @param array $button the button configuration which may contain 'label', 'url', 'data-icon', 'imageUrl' and 'options' elements.
 * @param integer $row the row number (zero-based)
 * @param mixed $data the data object associated with the row
 */
protected function renderButton($id, $button, $row, $data)