9{
12 $r =
$DIC[
'ui.renderer'];
13
14
15 $dummy_records = [
16 ['f1' => 'value1.1','f2' => 'value1.2','f3' => 1.11],
17 ['f1' => 'value2.1','f2' => 'value2.2','f3' => 2.22],
18 ['f1' => 'value3.1','f2' => 'value3.2','f3' => 4.44],
19 ['f1' => 'value4.1','f2' => 'value4.2','f3' => 8.88]
20 ];
21
22
24 'f1' =>
$f->table()->column()->text(
"Field 1")
25 ->withIsSortable(false),
26
27 'f0' =>
$f->table()->column()->text(
"empty"),
28
29 'f2' =>
$f->table()->column()->text(
"Field 2")
30 ->withIsOptional(true)
31 ->withIsInitiallyVisible(false),
32
33 'f3' =>
$f->table()->column()->number(
"Field 3")
34 ->withIsOptional(true)
35 ->withDecimals(2),
36
37 'f4' =>
$f->table()->column()->number(
"Field 4")
38 ->withIsOptional(false)
39 ];
40
41
42 $data_retrieval =
new class($dummy_records) extends
T\DataRetrieval {
43 protected $records;
44
46 {
47 $this->records = $dummy_records;
48 }
49
50 public function getRows(
51 I\RowFactory $row_factory,
54 array $visible_column_ids,
55 array $additional_parameters
56 ) : \Generator {
57 foreach ($this->records as $record) {
58
59 $record['f4'] = $record['f3'] * 2;
60
61 yield $row_factory->map($record);
62 }
63 }
64 };
65
66
67 $table =
$f->table()->data(
'a data table', 50)
69 ->withData($data_retrieval);
70
71
72 $request =
$DIC->http()->request();
73 return $r->render($table->withRequest($request));
74}
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a naive range of whole positive numbers.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc