0

有没有办法为生成的图像标签添加其他属性TbImageColoumn

文档对如何设置图像属性(如高度、宽度等)不是很清楚。它只提到了如何使用imagePathExpression属性添加图像 src,

我当前的专栏看起来像这样

           .....
            array(
                'class'=>'bootstrap.widgets.TbImageColumn',
                'imagePathExpression'=>'$data->getImage("large")',
                'usePlaceKitten'=>false,
                ),
           .....
4

1 回答 1

1

深入研究代码,似乎有一个属性用于使用 为生成的标签设置 html 属性,imageOptions并在生成的 td 单元格标签上设置属性,我们可以使用htmlOptions基类中的数组

/**
 * TbImageColumn widget class
 *
 * @package booster.widgets.grids.columns
 */
class TbImageColumn extends CGridColumn
{
    /**
     * @var array the HTML options of the image tag
     */
    public $imageOptions = array();

因此要将图像宽度限制为 50px,应将列修改为

           .....
            array(
                'class'=>'bootstrap.widgets.TbImageColumn',
                'imagePathExpression'=>'$data->getImage("large")',
                'headerHtmlOptions'=>array('style'=>'min-width: 50px;'),
                'imageOptions'=>array('width'=>'50px'),
                'usePlaceKitten'=>false,
            ),
           .....
于 2014-03-21T14:36:11.047 回答