Yii CGridView常用类型

<?php $this->widget('zii.widgets.grid.CGridView', array(
 'id'=>'chapter-grid',
 'dataProvider'=>$model->search(),  //数据结果集
 'filter'=>$model,     
 'columns'=>array(
      'id',
      //锚点<a href="http://www.gulianqiang.com/"></a>
       array(
              'name'=>'name',
              'type'=>'raw',
              'value'=>'CHtml::link($data->name,"/book/$data->id")',
         ),
      //图片
       array(
              'name'=>'image',
              'type'=>'image',
              'value'=>'LImages::getPath("book").$data->image',//图片相对路径
         ),
       //下拉列表
        array(
              'name'=>'type',
              'value'=>'Lookup::item("chapterType",$data->type)',
              'filter'=>Lookup::items('chapterType'),
         ),
       //内容截取
        array(
              'name'=>'content',
              'type'=>'html',
              'value'=>'mb_substr(htmlspecialchars_decode($data->content),0,100,"utf-8")',
         ),
               //时间
        array(
              'name'=>'create_time',
              'type'=>'datetime',
         ),
       // 根据相关信息读数据库
        array(
              'name'=>'user_id',
              'value'=>'User::model()->findbyPk($data->user_id)->username',
              'filter'=>false,
         ),
  array(
   'class'=>'CButtonColumn',
  ),
 ),
)); ?>


你可能感兴趣的:(yii,CGridView)