Beispiel #1
0
 protected function applySorting()
 {
     $sort = array();
     $this->sort = $this->sort ? $this->sort : $this->defaultSort;
     foreach ($this->sort as $column => $dir) {
         $component = $this->getColumn($column, FALSE);
         if (!$component) {
             if (!isset($this->defaultSort[$column])) {
                 trigger_error("Column with name '{$column}' does not exist.", E_USER_NOTICE);
                 break;
             }
         } elseif (!$component->isSortable()) {
             if (isset($this->defaultSort[$column])) {
                 $component->setSortable();
             } else {
                 trigger_error("Column with name '{$column}' is not sortable.", E_USER_NOTICE);
                 break;
             }
         }
         if (!in_array($dir, array(Column::ORDER_ASC, Column::ORDER_DESC))) {
             if ($dir == '' && isset($this->defaultSort[$column])) {
                 unset($this->sort[$column]);
                 break;
             }
             trigger_error("Dir '{$dir}' is not allowed.", E_USER_NOTICE);
             break;
         }
         $sort[$component ? $component->column : $column] = $dir == Column::ORDER_ASC ? 'ASC' : 'DESC';
     }
     if ($sort) {
         $this->model->sort($sort);
     }
 }
 public function sort(array $sorting)
 {
     $this->dataSource->sort($sorting);
 }