i have a table that one of column has value from function
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'camera-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'name'=>'location',
'header'=>'Location',
'value'=>'$data->location->name'
),
array(
'header'=>'Last Date',
'value'=>'$data->myfunction($data->location->name)'
),
),)); ?>
my questions is:
Thanks before :)
in the end, i found this solution. overall, i must make my custom variable as SQL query. So, i can sort or search custom variable like other variable from database.
in mymodel,
declare new variable
public $LAST_DATE;
add $criteria
$criteria->select = array('*','COALESCE(location.name, \'\') AS LAST_DATE');
$criteria->order = 'LAST_DATE DESC';
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'sort'=>array(
'defaultOrder'=>'LAST_DATE DESC',
'attributes' => array(
'LAST_DATE'=>array(
'asc'=>'COALESCE(location.name, \'\')',
'desc'=>'COALESCE(location.name, \'\') DESC',
),
'*',
),
),