Yii1:如何在CGridView中强制过滤列表来解析html?

时间:2016-01-06 15:36:27

标签: filter html-encode cgridview yii1.x

我有一个网格,在这个网格中我有过滤器。网格代码是:

$this->widget('booster.widgets.TbGridView', array(
        'id' => 'sam',
        'type' => 'striped bordered condensed',
        'dataProvider' => $dataProvider,
        'responsiveTable' => true,
        'enableHistory' => true,
        'filter' => $asset,
        'columns' => array(
            array(
                'name' => 'id',
                'header' => '#',
                'filter' => false,
                'type' => 'text',
            ),
            array(
                'name' => 'user',
                'header' => 'Registered By',
                'type' => 'text',
                'value' => '$data["assignedBy"]',
            ),
            array(
                'name' => 'createdAt',
                'header' => 'Created At',
                'type' => 'datetime',
            ),
            array(
                'name' => 'serial',
                'header' => 'Serial',
            ),
            array(
                'name' => 'brand',
                'header' => 'Brand',
            ),
            array(
                'name' => 'model',
                'header' => 'Model',
            ),
            array(
                'name' => 'assetType',
                'type' => 'text',
                'filter' => \wsi\it\model\AssetType::getRepository()->getTypeTree(),
                'value' => '$data["assetTypeName"]',
                'header' => 'Type',
            ),
            array(
                'name' => 'assigned',
                'value' => '(isset($data["assignedTo"]))? $data["assignedTo"]:null',
                'header' => 'Assigned To',
            ),
            array(
                'name' => 'location',
                'filter' => \wsi\hr\Facade::getInstance()->getLocations(),
                'value' => '$data["locationName"]',
                'header' => 'Location',
            ),
            array(
                'name' => 'status',
                'header' => 'Status',
                'filter' => \wsi\it\model\Asset::$statusOptionList,
                'value' => '\wsi\it\model\Asset::$statusOptionList[$data["status"]]',
            ),
            array(
                'class' => 'booster.widgets.TbButtonColumn',
                'template' => '{view} {update} {delete}',
                'header' => '',
                'buttons' => array(
                    'update' => array(
                        'url' => '\Yii::app()->controller->createUrl("asset/create", array("id"=>$data["id"]))',
                    ),
                    'view' => array(
                        'url' => '\Yii::app()->controller->createUrl("asset/view", array("id"=>$data["id"]))',
                    ),
                    'delete' => array(
                        'url' => '\Yii::app()->controller->createUrl("asset/delete", array("id"=>$data["id"]))',
                    ),
                ),
            ),
        )
    )
);

当在浏览器中呈现网格时,您可以看到过滤器列表框包含未完全解析的html!

I am talking about these $nbsp; in the filter list box

之前我遇到过Yii-Booster的这个问题,我用一个选项解决了这个问题,我把它传递给了这个小部件('htmlOptions'=> 'encode'=> false )并且它可以防止 被视为字符串,因此浏览器会将其解析为空格。您可以在下面看到的代码不适用于网格过滤器!

$form->dropDownListGroup($formModel, 'segmentList', array(
        'wrapperHtmlOptions' => array(
            'class' => 'col-md-6'
        ),
        'widgetOptions' => array(
            'data' => $segmentTreeArray,
            'htmlOptions' => array(
           >>>  'encode' => false, <<<                    
            )
        ),
        'hint' => "Press CTRL to add another item, otherwise others will be deselected",
    ));

但是我确信我必须将相同的"encode" => false传递给过滤器列表,我只是找不到我应该传递的密钥(htmlOptions不起作用)。< / p>

0 个答案:

没有答案