dongqingcheng2903 2011-05-27 09:27
浏览 29
已采纳

Yii CGridView列值,从模型中实现

I wanna make some CGridView table in a view. And one column should contain DropDown list. Main problem is, that this dropdown list must be generated by model.

So, in my view i made it like this:

$this->widget('zii.widgets.grid.CGridView', array(
                'dataProvider'=>$orders->search(),
                'filter' => $orders,
                'columns' => array(
                    array(
                        'name' => 'actions',
                        'header' => 'Actions',
                        'value' => '$data->actions',
                        'filter' => false,


    ),
));

And in Order model:

public function getActions() {
    return CHtml::dropDownList('status', $this->status->id,  CHtml::listData(Status::model()->findAll(), 'id', 'title'));
}

And i getting pretty nice column value with code of this dropdown list, but all special chracters encoded to lt; quot; gt; etc. Just string, not html element.

So, how to get real html dropdown list?

[SOLVED] just adding 'type' => 'raw' for this column solved all this problems

  • 写回答

1条回答 默认 最新

  • dtdvbf37193 2011-05-27 11:42
    关注

    Special characters in a CGridView are encoded by default. Try adding the following to your columns array:

    'type' => 'raw' 
    

    // Edit: Oops, read your question too fast. I see you've already found the solution yourself. :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测