> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/de/powershell-befehle/new-udtable.md).

# New-UDTable

New-UDTable erstellt eine Datentabelle in PowerShell Universal mit Unterstützung für Sortierung, Filterung, Suche, Paging und serverseitiges Laden von Daten.

### Übersicht

Erstellt eine Tabelle.

### Syntax

```powershell
New-UDTable [-Id <String>] [-Title <String>] [-Data <Object[]>] [-Columns <Hashtable[]>] [-OnRowSelection <Endpoint>] [-ShowSort] [-ShowFilter] [-ShowSearch] [-Dense] [-ShowExport] [-StickyHeader] [-PageSize <Int32>] [-PageSizeOptions <Int32[]>] [-PaginationLocation <String>] [-ShowSelection] [-ShowPagination] [-Padding <String>] [-Size <String>] [-TextOption <Hashtable>] [-ExportOption <String[]>] [-OnExport <Endpoint>] [-DisablePageSizeAll] [-DefaultSortDirection <String>] [-HideToggleAllRowsSelected] [-DisableMultiSelect] [-DisableSortRemove] [-Icon <Hashtable>] [-ClassName <String>] [-ShowRefresh] [-ToolbarContent <ScriptBlock>] [-OnRowExpand <ScriptBlock>] [-MaxHeight <Int32>] [-Language <String>] [-RemoveCard] [-OnRowStyle <ScriptBlock>] [-HeaderStyle <Hashtable>] [-InitialState <Hashtable>] [<CommonParameters>]

New-UDTable [-Id <String>] [-Title <String>] -LoadRows <Endpoint> [-Columns <Hashtable[]>] [-OnRowSelection <Endpoint>] [-ShowSort] [-ShowFilter] [-ShowSearch] [-Dense] [-ShowExport] [-StickyHeader] [-PageSize <Int32>] [-PageSizeOptions <Int32[]>] [-PaginationLocation <String>] [-ShowSelection] [-ShowPagination] [-Padding <String>] [-Size <String>] [-TextOption <Hashtable>] [-ExportOption <String[]>] [-OnExport <Endpoint>] [-DisablePageSizeAll] [-DefaultSortDirection <String>] [-HideToggleAllRowsSelected] [-DisableMultiSelect] [-DisableSortRemove] [-Icon <Hashtable>] [-ClassName <String>] [-ShowRefresh] [-ToolbarContent <ScriptBlock>] [-OnRowExpand <ScriptBlock>] [-MaxHeight <Int32>] [-AutoRefresh] [-AutoRefreshInterval <Int32>] [-Language <String>] [-RemoveCard] [-OnRowStyle <ScriptBlock>] [-HeaderStyle <Hashtable>] [-InitialState <Hashtable>] [<CommonParameters>]
```

### Beschreibung

Erstellt eine Tabelle. Tabellen werden verwendet, um sowohl statische als auch dynamische Daten anzuzeigen. Sie können Spalten und Daten definieren, die in der Tabelle angezeigt werden sollen. Die Spalten können verwendet werden, um benutzerdefinierte Komponenten basierend auf Zeilendaten zu rendern. Sie können außerdem Paging, Filterung, Sortierung und sogar serverseitige Verarbeitung aktivieren.

### Parameter

#### -Id

Die ID der Komponente. Standardmäßig ist es eine zufällige GUID.

```
Required?                    false
Position?                    named
Default value                [Guid]::NewGuid().ToString()
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Title

Der Titel, der oben auf der Karte der Tabelle angezeigt wird.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Data \<Object\[]>

Die Daten, die in die Tabelle eingefügt werden sollen.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -LoadRows

Bei Verwendung dynamischer Tabellen wird dieser Skriptblock aufgerufen. Der Parameter $Body enthält eine Hashtable mit den folgenden Optionen:

filters: @() orderBy: string orderDirection: string page: int pageSize: int properties: @() search: string totalCount: int

Sie können diese Werte verwenden, um eine serverseitige Verarbeitung, wie z. B. SQL-Abfragen, durchzuführen und so die Leistung großer Raster zu verbessern.

Nachdem Sie die Daten mit diesen Werten verarbeitet haben, geben Sie die Daten über Out-UDTableData aus.

```
Required?                    true
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Columns \<Hashtable\[]>

Definiert die Spalten, die in der Tabelle angezeigt werden sollen. Verwenden Sie New-UDTableColumn, um diese Spalten zu definieren. Wenn dieser Parameter nicht angegeben wird, werden die Eigenschaften der übergebenen Daten zu den Spalten.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OnRowSelection

Ein Skriptblock, der aufgerufen wird, wenn eine Zeile ausgewählt wird. $EventData enthält die ausgewählten Zeilen.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ShowSort

Ob Sortiersteuerelemente in Spalten angezeigt werden

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ShowFilter

Ob Filtersteuerelemente in Spalten angezeigt werden

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ShowSearch

Ob die Suche für die gesamte Tabelle angezeigt wird

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Dense

Reduziert den in der Tabelle verwendeten Leerraum.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ShowExport

Ob die Export-Schaltfläche angezeigt wird.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -StickyHeader

Macht die Kopfzeile fixiert.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -PageSize

Die Standardseitengröße.

```
Required?                    false
Position?                    named
Default value                5
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -PageSizeOptions \<Int32\[]>

Ein Array verfügbarer Seitengrößenoptionen.

```
Required?                    false
Position?                    named
Default value                @()
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -PaginationLocation

Wo die Paginierungssteuerelemente angezeigt werden sollen. Gültige Werte sind top, bottom oder both. Standardmäßig bottom.

```
Required?                    false
Position?                    named
Default value                bottom
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ShowSelection

Ob eine Auswahl innerhalb der Tabelle erlaubt ist.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ShowPagination

Ob Paginierungssteuerelemente angezeigt werden.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Padding

```
Required?                    false
Position?                    named
Default value                default
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Size

Die Größe der Tabelle. Standardmäßig medium. Gültige Werte sind medium und small.

```
Required?                    false
Position?                    named
Default value                medium
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -TextOption

Anpassungen des Standardtexts innerhalb der Tabelle. Verwenden Sie New-UDTextOption, um die Textoptionen zu erstellen.

```
Required?                    false
Position?                    named
Default value                (New-UDTableTextOption)
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ExportOption \<String\[]>

Ein Array von Exportoptionen.

```
Required?                    false
Position?                    named
Default value                @("XLSX", "PDF", "JSON", "CSV")
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OnExport

Ein Skriptblock, mit dem angepasst wird, wie der Export durchgeführt wird.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -DisablePageSizeAll

Entfernt die Option All aus den Seitengrößenoptionen.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -DefaultSortDirection

Die Standardsortierrichtung.

```
Required?                    false
Position?                    named
Default value                ascending
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -HideToggleAllRowsSelected

Verbirgt die Schaltfläche zum Umschalten der Auswahl aller Zeilen.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -DisableMultiSelect

Deaktiviert die Mehrfachauswahl.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -DisableSortRemove

Entfernt die Sortieroption für unsortierte Spalten. Spalten werden immer aufsteigend oder absteigend sortiert.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Icon

Legt ein Symbol neben dem Titel fest. Verwenden Sie New-UDIcon, um das Symbol zu erstellen.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ClassName

Eine CSS-Klasse, die auf die Tabelle angewendet wird.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ShowRefresh

Ob die Aktualisierungsschaltfläche angezeigt wird.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ToolbarContent

Benutzerdefinierter Inhalt, der in der Symbolleiste angezeigt wird.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OnRowExpand

Ein Skriptblock, der aufgerufen wird, wenn eine Zeile erweitert wird. Die Variable $EventData enthält die Zeilendaten.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -MaxHeight

```
Required?                    false
Position?                    named
Default value                0
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -AutoRefresh

Lädt die Tabelle in einem Intervall neu, wenn -LoadRows verwendet wird.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -AutoRefreshInterval

Das Intervall, in dem die Daten neu geladen werden, wenn AutoRefresh angegeben ist.

```
Required?                    false
Position?                    named
Default value                10
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Language

Die Sprache. Wird hauptsächlich für Datums- und Zeitfilter verwendet.

```
Required?                    false
Position?                    named
Default value                en
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -RemoveCard

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OnRowStyle

Ein Skriptblock, der aufgerufen wird, um Zeilen zu stylen. Die Variable $EventData enthält die Zeilendaten.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -HeaderStyle

Eine Hashtable mit Stilen, die auf die Kopfzeile angewendet werden.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -InitialState

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### Allgemeine Parameter

Dieses Cmdlet unterstützt die allgemeinen Parameter: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter [about\_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

### Ausgaben

### Beispiele

#### Beispiel 1: Einfache Tabelle

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
)
New-UDTable -Data $Data -Id 'table1'
```

Erstellt eine statische Tabelle, bei der die Spalten der Tabelle die Eigenschaften der angegebenen Daten sind.

#### Beispiel 2: Spalten

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
)
$Columns = @(
    New-UDTableColumn -Property Dessert -Title "A Dessert"
    New-UDTableColumn -Property Calories -Title Calories
    New-UDTableColumn -Property Fat -Title Fat
    New-UDTableColumn -Property Carbs -Title Carbs
    New-UDTableColumn -Property Protein -Title Protein
)
New-UDTable -Data $Data -Columns $Columns -Id 'table2'
```

Erstellt eine Tabelle, für die benutzerdefinierte Spalten definiert sind.

#### Beispiel 3: Rendern

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
)
$Columns = @(
    New-UDTableColumn -Property Dessert -Title Dessert -Render {
       New-UDButton -Id "btn$($EventData.Dessert)" -Text "Click for Dessert!" -OnClick { Show-UDToast -Message $EventData.Dessert }
    }
    New-UDTableColumn -Property Calories -Title Calories
    New-UDTableColumn -Property Fat -Title Fat
    New-UDTableColumn -Property Carbs -Title Carbs
    New-UDTableColumn -Property Protein -Title Protein
)
New-UDTable -Data $Data -Columns $Columns -Id 'table3'
```

Erstellt eine Tabelle, bei der die Spalten mit benutzerdefiniertem Inhalt gerendert werden.

#### Beispiel 4: Spaltenbreite

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
)

$Columns = @(
    New-UDTableColumn -Property Dessert -Title Dessert -Render {
        New-UDButton -Id "btn$($EventData.Dessert)" -Text "Click for Dessert!" -OnClick { Show-UDToast -Message $EventData.Dessert }
    }
    New-UDTableColumn -Property Calories -Title Calories -Width 5 -Truncate
    New-UDTableColumn -Property Fat -Title Fat
    New-UDTableColumn -Property Carbs -Title Carbs
    New-UDTableColumn -Property Protein -Title Protein
)

New-UDTable -Data $Data -Columns $Columns -Id 'table4'
```

Benutzerdefinierte Spaltenbreite festlegen

#### Beispiel 5: Spaltenfilter

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
)

$Columns = @(
    New-UDTableColumn -Property Dessert -Title "A Dessert" -Filter -FilterType AutoComplete
    New-UDTableColumn -Property Calories -Title Calories -Filter -FilterType Range
    New-UDTableColumn -Property Fat -Title Fat -Filter -FilterType Range
    New-UDTableColumn -Property Carbs -Title Carbs -Filter -FilterType Range
    New-UDTableColumn -Property Protein -Title Protein -Filter -FilterType Range
)

New-UDTable -Id 'table5' -Data $Data -Columns $Columns -ShowFilter
```

Spaltenfilter für eine Tabelle

#### Beispiel 6: Spaltensuche

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
)

$Columns = @(
    New-UDTableColumn -Property Dessert -Title "A Dessert" -IncludeInSearch
    New-UDTableColumn -Property Calories -Title Calories
    New-UDTableColumn -Property Fat -Title Fat
    New-UDTableColumn -Property Carbs -Title Carbs
    New-UDTableColumn -Property Protein -Title Protein
)

New-UDTable -Id 'table6' -Data $Data -Columns $Columns -ShowSearch
```

Spalten können in die Suche einbezogen werden

#### Beispiel 7: Serverseitige Verarbeitung

```powershell
$Columns = @(
    New-UDTableColumn -Property Name -Title "Name" -ShowFilter
    New-UDTableColumn -Property Value -Title "Value" -ShowFilter
)

$Data = 1..1000 | ForEach-Object {
    [PSCustomObject]@{
        Name = "Record-$_"
        Value = $_
    }
}

New-UDTable -Columns $Columns -LoadData {
    foreach($Filter in $EventData.Filters)
    {
        $Data = $Data | Where-Object -Property $Filter.Id -Match -Value $Filter.Value
    }

    $TotalCount = $Data.Count

    if (-not [string]::IsNullOrEmpty($EventData.OrderBy.Field))
    {
        $Descending = $EventData.OrderDirection -ne 'asc'
        $Data = $Data | Sort-Object -Property ($EventData.orderBy.Field) -Descending:$Descending
    }

    $Data = $Data | Select-Object -First $EventData.PageSize -Skip ($EventData.Page * $EventData.PageSize)

    $Data | Out-UDTableData -Page $EventData.Page -TotalCount $TotalCount -Properties $EventData.Properties
} -ShowFilter -ShowSort -ShowPagination -Id 'table7'
```

Serverseitige Verarbeitung ist nützlich für große Datensätze, die nicht in den Browser geladen werden sollten.

#### Beispiel 8: Paging

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
)

New-UDTable -Data $Data -Paging -PageSize 2 -Id 'table8'
```

Paging kann aktiviert werden, indem der Parameter -Paging auf $true gesetzt wird. Die Standardseitengröße ist 10.

#### Beispiel 9: Zeilenerweiterung

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
)

New-UDTable -Data $Data -OnRowExpand {
    New-UDAlert -Text $EventData.Calories
} -Columns @(
    New-UDTableColumn -Title 'Dessert' -Property 'Dessert'
) -Id 'table9'
```

Die Zeilenerweiterung kann aktiviert werden, indem der Parameter -OnRowExpand auf einen Skriptblock gesetzt wird. Dem Skriptblock werden die Zeilendaten als Hashtable in der Variablen $EventData übergeben.

#### Beispiel 10: Export

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
)

$Columns = @(
    New-UDTableColumn -Property Dessert -Title "A Dessert" -IncludeInExport
    New-UDTableColumn -Property Calories -Title Calories -IncludeInExport
    New-UDTableColumn -Property Fat -Title Fat -IncludeInExport
    New-UDTableColumn -Property Carbs -Title Carbs -IncludeInExport
    New-UDTableColumn -Property Protein -Title Protein -IncludeInExport -Hidden
)

New-UDTable -Id 'table10' -Data $Data -Columns $Columns -Export
```

Exportieren Sie Tabellendaten mit dem Parameter -Export. Sie können konfigurieren, welche Spalten in den Export einbezogen werden, indem Sie den Parameter -IncludeInExport für die Spalte festlegen. Verwenden Sie -Hidden, um eine Spalte in der Tabelle zu verbergen, sie jedoch in den Export einzubeziehen.

#### Beispiel 11: Textoptionen

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
)

$Option = New-UDTableTextOption -Search "Search all these records"

New-UDTable -Data $Data -TextOption $Option -ShowSearch -Id 'table11'
```

Textoptionen können verwendet werden, um den Text in der Tabelle anzupassen.

#### Beispiel 12: Zeilen-Styling

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0 }
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0 }
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0 }
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0 }
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0 }
)

New-UDTable -Data $Data -OnRowStyle {
    if ($EventData.Dessert -eq 'Frozen yoghurt')
    {
        @{
            backgroundColor = "red"
        }
    } else {
        @{}
    }
} -Id 'table12'
```

Sie können Zeilen mit dem Parameter -OnRowStyle stylen. Dem Skriptblock werden die Zeilendaten als Hashtable in der Variablen $EventData übergeben. Der Skriptblock sollte eine Hashtable mit CSS-Stilen zurückgeben, die auf die Zeile angewendet werden.

#### Beispiel 13: Standardsortierung

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 1; Protein = 4.0 }
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 34; Protein = 4.0 }
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 73; Protein = 4.0 }
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 25; Protein = 4.0 }
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 99; Protein = 4.0 }
)
$Columns = @(
    New-UDTableColumn -Property Dessert -Title "Dessert"
    New-UDTableColumn -Property Calories -Title "Calories"
    New-UDTableColumn -Property Fat -Title "Fat"
    New-UDTableColumn -Property Carbs -Title "Carbs" -DefaultSortColumn
    New-UDTableColumn -Property Protein -Title "Protein"
)
New-UDTable -Data $Data -DefaultSortDirection descending -Id 'table13' -ShowSort -Columns $Columns
```

Legen Sie die Standardsortierrichtung und -spalte fest.

#### Beispiel 14: Anfangszustand

```powershell
$Data = 1..100 | ForEach-Object {
    [PSCustomObject]@{
        Dessert = "Dessert $_"
        Calories = Get-Random -Minimum 100 -Maximum 500
        Fat = Get-Random -Minimum 1 -Maximum 10
        Carbs = Get-Random -Minimum 1 -Maximum 100
        Protein = Get-Random -Minimum 1 -Maximum 100
    }
}
$Columns = @(
    New-UDTableColumn -Property Dessert -Title "Dessert" -ShowFilter
    New-UDTableColumn -Property Calories -Title "Calories"
    New-UDTableColumn -Property Fat -Title "Fat"
    New-UDTableColumn -Property Carbs -Title "Carbs"
    New-UDTableColumn -Property Protein -Title "Protein"
)
New-UDTable -Id 'table14' -ShowPagination -LoadData {
    foreach($Filter in $EventData.Filters)
    {
        $Data = $Data | Where-Object -Property $Filter.Id -Match -Value $Filter.Value
    }
    $TotalCount = $Data.Count
    if (-not [string]::IsNullOrEmpty($EventData.OrderBy))
    {
        $Descending = $EventData.OrderDirection -ne 'asc'
        $Data = $Data | Sort-Object -Property $EventData.orderBy.field -Descending:$Descending
    }

    $Data = $Data | Select-Object -First $EventData.PageSize -Skip ($EventData.Page * $EventData.PageSize)
    $Data | Out-UDTableData -Page $EventData.Page -TotalCount $TotalCount -Properties $EventData.Properties
} -Columns $Columns -InitialState @{
    pageIndex = 0
    pageSize = 20
    filters = @{
        id = "dessert"
        value = "20"
    }
    orderBy = @{ field = "fat" }
} -ShowSort
```

Legen Sie den Anfangszustand der Tabelle fest. Damit können der Seitenindex, die Seitengröße, Filter und die Sortierspalte festgelegt werden.

#### Beispiel 15: Zeilenfärbung

```powershell
$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 1; Protein = 4.0 }
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 150.0; Carbs = 34; Protein = 4.0 }
    @{Dessert = 'Eclair'; Calories = 159; Fat = 100.0; Carbs = 73; Protein = 4.0 }
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 30.0; Carbs = 25; Protein = 4.0 }
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 99; Protein = 4.0 }
)
$Columns = @(
    New-UDTableColumn -Property Dessert -Title "Dessert"
    New-UDTableColumn -Property Calories -Title "Calories"
    New-UDTableColumn -Property Fat -Title "Fat"
    New-UDTableColumn -Property Carbs -Title "Carbs" -DefaultSortColumn
    New-UDTableColumn -Property Protein -Title "Protein"
)
New-UDTable -Data $Data -Id 'table14' -Columns $Columns -OnRowStyle {
    if ($EventData.Fat -lt 10) { $Color = 'green' }
    elseif ($EventData.Fat -ge 10 -and $EventData.Fat -lt 50) { $Color = 'Yellow' }
    else { $Color = 'Red' }
    @{ backgroundColor = $Color }
}
```

Verwenden Sie OnRowStyle, um Zeilen basierend auf den Zeilendaten zu formatieren.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.devolutions.net/powershell-universal/de/powershell-befehle/new-udtable.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
