UPDATE-RATE

Die Test-Installation wird aktuell zwischen 8:00 und 18:00 Uhr stündlich zur vollen Stunde aktualisiert.

Alles neu macht der Mai

ILIAS 9 ist da! Alle Infos zu den Highlights der neuen Version gibt es hier!

Documentation

Kitchen Sink documentation of style: 'Delos' of skin: 'ILIAS'

Number

Description

Purpose
The Number Column is used for numeric values.

Example 1: Base

Number Columns

some number: 123 with decimals: 123,00 with unit before: € 123 with unit after: 123,00 Eur
some number: 46 with decimals: 45,66 with unit before: € 46 with unit after: 45,66 Eur
some number: 79 with decimals: 78,99 with unit before: € 79 with unit after: 78,99 Eur
<?php
 
declare(strict_types=1);
 
namespace ILIAS\UI\examples\Table\Column\Number;
 
use ILIAS\UI\Implementation\Component\Table as T;
use ILIAS\UI\Component\Table as I;
use ILIAS\Data\Range;
use ILIAS\Data\Order;
 
function base()
{
    global $DIC;
    $f = $DIC['ui.factory'];
    $r = $DIC['ui.renderer'];
 
    $dummy_records = [123, 45.66, 78.9876];
 
    $columns = [
        'n1' => $f->table()->column()->number("some number"),
        'n2' => $f->table()->column()->number("with decimals")
            ->withDecimals(2),
        'n3' => $f->table()->column()->number("with unit before")
            ->withUnit('€', I\Column\Number::UNIT_POSITION_FORE),
        'n4' => $f->table()->column()->number("with unit after")
            ->withDecimals(2)
            ->withUnit('Eur', I\Column\Number::UNIT_POSITION_AFT),
    ];
 
    $data_retrieval = new class ($dummy_records) implements I\DataRetrieval {
        protected array $records;
 
        public function __construct(array $dummy_records)
        {
            $this->records = $dummy_records;
        }
 
        public function getRows(
            I\DataRowBuilder $row_builder,
            array $visible_column_ids,
            Range $range,
            Order $order,
            ?array $filter_data,
            ?array $additional_parameters
        ): \Generator {
            foreach ($this->records as $number) {
                $row_id = '';
                for ($i = 1; $i < 5; $i++) {
                    $record['n' . $i] = $number;
                }
                yield $row_builder->buildDataRow($row_id, $record);
            }
        }
 
        public function getTotalRowCount(
            ?array $filter_data,
            ?array $additional_parameters
        ): ?int {
            return count($this->records);
        }
    };
 
    $table = $f->table()->data('Number Columns', $columns, $data_retrieval)
        ->withRequest($DIC->http()->request());
    return $r->render($table);
}
 

Relations

Parents
  1. UIComponent
  2. Table
  3. Column