Minggu, 01 Oktober 2017

cgridview link

array(
'header'=>'Nama Rancangan Peraturan Menteri',
//'name'=>'nama_rancangan',
//'value'=> '$data->rancangan->nama',
'value' => 'CHtml::link($data->nama_rancangan,Yii::app()->createAbsoluteUrl("/rancangan/detail",array("id"=>$data->id)))',
'type'  => 'raw',
),

Encode

$this->widget('zii.widgets.grid.CGridView', array(
 'dataProvider' => $model->search(),
 'filter' => $model,
 'columns' => array(
  array(
   'name' => 'username',
   'type' => 'raw',
   'value' => 'CHtml::encode($data->username)'
  ),
  array(
   'name' => 'email',
   'type' => 'raw',
   'value' => 'CHtml::link(CHtml::encode($data->email), "mailto:".CHtml::encode($data->email))',
  ),
 ),
));

Pagination Yii1

    $perPage = 2;
    $offset = ($page > 1) ? ($page * $perPage) - $perPage : 0;

    $criteria = new CDbCriteria;
    $criteria->order = 'id DESC';
    $criteria->limit=$perPage;
    $criteria->offset=$offset;

    $templates = Users::model()->findAll($criteria);