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. :)

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

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改