Example #1
0
 /**
  * Create column sortable link
  *
  * @param \Engine\Crud\Grid\Field $column
  * @return string
  */
 public static function sortLink(Field $column)
 {
     $grid = $column->getGrid();
     $action = $grid->getAction();
     $sortDirection = $column->getSortDirection();
     $sorted = $column->isSorted();
     $params = $column->getSortParams();
     if ($action) {
         $action = '/' . $action . '/?' . http_build_query($params);
     } else {
         $action = '/?' . http_build_query($params);
     }
     $link = '';
     $sortIcon = '';
     if ($sorted) {
         $link .= '<b>';
         $sortIcon = $sortDirection == "asc" ? "/\\" : "\\/";
     }
     $link .= '<a href="' . $action . '">' . $column->getTitle() . " " . $sortIcon . "</a>";
     if ($sorted) {
         $link .= '</b>';
     }
     return $link;
 }