19declare(strict_types=1);
30 protected ?
Order $order =
null;
40 $sortable_visible_cols = array_filter(
42 static fn(
$c):
bool =>
$c->isSortable()
44 if ($sortable_visible_cols === []) {
45 return array_key_first($visible_cols);
47 return array_key_first($sortable_visible_cols);
53 $sortable_visible_cols = array_filter(
55 static fn(
$c):
bool =>
$c->isSortable()
58 if ($sortable_visible_cols === [] ||
59 ($total_count !==
null && $total_count < 2)
61 return $this->view_control_factory->group([
62 $this->view_control_factory->nullControl(),
63 $this->view_control_factory->nullControl()
68 foreach ($sortable_visible_cols as $col_id => $col) {
70 $order_asc = $this->data_factory->order($col_id,
Order::ASC);
71 $order_desc = $this->data_factory->order($col_id,
Order::DESC);
73 $labels = $col->getOrderingLabels();
74 $sort_options[$labels[0]] = $order_asc;
75 $sort_options[$labels[1]] = $order_desc;
78 $value = $this->
getOrder()->join(
'', fn($ret, $key, $value) => [$key, $value]);
79 return $this->view_control_factory->sortation($sort_options)
86 $clone->order = $order;
Both the subject and the direction need to be specified when expressing an order.
A Column describes the form of presentation for a certain aspect of data, i.e.
trait TableViewControlOrdering
getViewControlOrdering(int|null $total_count)
initViewControlOrdering()