Код: Выделить всё
public function getDirections()
{
if($this->_directions===null)
{
$this->_directions = array();
if(isset($_GET[$this->sortVar]) !== FALSE)
{
$attributes = explode($this->separators[0], $_GET[$this->sortVar]);
foreach($attributes as $attribute)
{
$segments = explode($this->separators[1], $attribute);
$count = count($segments);
$descending = FALSE;
if ($count > 0)
{
if (strcasecmp($segments[$count - 1], $this->descTag) === 0)
{
$descending = TRUE;
unset($segments[$count - 1]);
$attribute = implode($this->separators[1], $segments);
}
}
if ($this->resolveAttribute($attribute) != FALSE)
{
$this->_directions[$attribute] = $descending;
if ($this->multiSort == FALSE)
{
return $this->_directions;
}
}
}
}
if (count($this->_directions) === 0)
{
if (is_array($this->defaultOrder) === TRUE)
{
$this->_directions = $this->defaultOrder;
}
}
}
return $this->_directions;
}
1. CActiveDataProvider добавить конфигурацию сортировки:
Код: Выделить всё
'dataProvider' => array(
'sort' => array(
'attributes' => array(
'id',
'element.created' => array(
'asc' => 'element.created',
'desc' => 'element.created DESC',
'label' => 'Name from config'
)
)
)
)
3. поле element.created в конфигурации columns для СGridView
4. в конфигурацию CDbCriteria для CActiveDataProvider
Код: Выделить всё
'criteria' => array(
'with' => array(
'element'
)
)