> 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/it/comandi-powershell/new-udtable.md).

# New-UDTable

New-UDTable crea una tabella dati in PowerShell Universal con supporto per ordinamento, filtri, ricerca, paginazione e caricamento dei dati lato server.

### Sinossi

Crea una tabella.

### Sintassi

```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>]
```

### Descrizione

Crea una tabella. Le tabelle vengono utilizzate per mostrare dati sia statici sia dinamici. È possibile definire le colonne e i dati da mostrare all'interno della tabella. Le colonne possono essere utilizzate per eseguire il rendering di componenti personalizzati in base ai dati della riga. È inoltre possibile abilitare la paginazione, i filtri, l'ordinamento e persino l'elaborazione lato server.

### Parametri

#### -Id

L'ID del componente. Per impostazione predefinita è un GUID casuale.

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

#### -Title

Il titolo da mostrare nella parte superiore della card della tabella.

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

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

I dati da inserire nella tabella.

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

#### -LoadRows

Quando si utilizzano tabelle dinamiche, viene richiamato questo blocco di script. Il parametro $Body conterrà una hashtable con le seguenti opzioni:

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

È possibile utilizzare questi valori per eseguire l'elaborazione lato server, come query SQL, per migliorare le prestazioni delle griglie di grandi dimensioni.

Dopo aver elaborato i dati con questi valori, restituisca i dati tramite Out-UDTableData.

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

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

Definisce le colonne da mostrare all'interno della tabella. Utilizzi New-UDTableColumn per definire queste colonne. Se questo parametro non viene specificato, le proprietà dei dati passati diventeranno le colonne.

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

#### -OnRowSelection

Un blocco di script da richiamare quando viene selezionata una riga. $EventData conterrà le righe selezionate.

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

#### -ShowSort

Se mostrare i controlli di ordinamento sulle colonne

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

#### -ShowFilter

Se mostrare i controlli di filtro sulle colonne

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

#### -ShowSearch

Se mostrare la ricerca sull'intera tabella

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

#### -Dense

Riduce lo spazio bianco utilizzato all'interno della tabella.

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

#### -ShowExport

Se mostrare il pulsante di esportazione.

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

#### -StickyHeader

Rende l'intestazione fissa.

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

#### -PageSize

La dimensione di pagina predefinita.

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

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

Un array delle opzioni di dimensione di pagina disponibili.

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

#### -PaginationLocation

Dove mostrare i controlli di paginazione. I valori validi sono top, bottom o both. Il valore predefinito è bottom.

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

#### -ShowSelection

Se consentire la selezione all'interno della tabella.

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

#### -ShowPagination

Se mostrare i controlli di paginazione.

```
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

La dimensione della tabella. Il valore predefinito è medium. I valori validi sono medium e small.

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

#### -TextOption

Personalizzazioni del testo standard all'interno della tabella. Utilizzi New-UDTextOption per creare le opzioni di testo.

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

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

Un array di opzioni di esportazione.

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

#### -OnExport

Un blocco di script utilizzato per personalizzare la modalità di esportazione.

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

#### -DisablePageSizeAll

Rimuove l'opzione All dalle opzioni di dimensione di pagina.

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

#### -DefaultSortDirection

La direzione di ordinamento predefinita.

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

#### -HideToggleAllRowsSelected

Nasconde il pulsante per selezionare/deselezionare tutte le righe.

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

#### -DisableMultiSelect

Disabilita la selezione multipla.

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

#### -DisableSortRemove

Rimuove l'opzione di ordinamento per le colonne non ordinate. Le colonne saranno sempre in ordine crescente o decrescente.

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

#### -Icon

Imposta un'icona accanto al titolo. Utilizzi New-UDIcon per creare l'icona.

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

#### -ClassName

Una classe CSS da applicare alla tabella.

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

#### -ShowRefresh

Se mostrare il pulsante di aggiornamento.

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

#### -ToolbarContent

Contenuto personalizzato da mostrare nella barra degli strumenti.

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

#### -OnRowExpand

Un blocco di script da richiamare quando una riga viene espansa. La variabile $EventData conterrà i dati della riga.

```
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

Ricarica la tabella a intervalli regolari quando viene utilizzato -LoadRows.

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

#### -AutoRefreshInterval

L'intervallo di ricaricamento dei dati quando è specificato AutoRefresh.

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

#### -Language

La lingua. Utilizzata principalmente per i filtri di data e ora.

```
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

Un blocco di script da richiamare per applicare uno stile alle righe. La variabile $EventData conterrà i dati della riga.

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

#### -HeaderStyle

Una hashtable di stili da applicare all'intestazione.

```
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
```

#### Parametri comuni

Questo cmdlet supporta i parametri comuni: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable e OutVariable. Per maggiori informazioni, veda [about\_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

### Output

### Esempi

#### Esempio 1: tabella di base

```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'
```

Crea una tabella statica in cui le colonne della tabella sono le proprietà dei dati specificati.

#### Esempio 2: colonne

```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'
```

Crea una tabella in cui sono definite colonne personalizzate per quella tabella.

#### Esempio 3: rendering

```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'
```

Crea una tabella in cui il rendering delle colonne avviene con contenuto personalizzato.

#### Esempio 4: larghezza delle colonne

```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'
```

Impostare una larghezza di colonna personalizzata

#### Esempio 5: filtro delle colonne

```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
```

Filtri delle colonne per una tabella

#### Esempio 6: ricerca nelle colonne

```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
```

Le colonne possono essere incluse nella ricerca

#### Esempio 7: elaborazione lato server

```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'
```

L'elaborazione lato server è utile per set di dati di grandi dimensioni che non dovrebbero essere caricati nel browser.

#### Esempio 8: paginazione

```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'
```

La paginazione può essere abilitata impostando il parametro -Paging su $true. La dimensione di pagina predefinita è 10.

#### Esempio 9: espansione delle righe

```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'
```

L'espansione delle righe può essere abilitata impostando il parametro -OnRowExpand su un blocco di script. Al blocco di script verranno passati i dati della riga come hashtable nella variabile $EventData.

#### Esempio 10: esportazione

```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
```

Esporti i dati della tabella con il parametro -Export. È possibile configurare quali colonne includere nell'esportazione impostando il parametro -IncludeInExport sulla colonna. Utilizzi -Hidden per nascondere una colonna nella tabella ma includerla nell'esportazione.

#### Esempio 11: opzioni di testo

```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'
```

Le opzioni di testo possono essere utilizzate per personalizzare il testo nella tabella.

#### Esempio 12: stile delle righe

```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'
```

È possibile applicare uno stile alle righe utilizzando il parametro -OnRowStyle. Al blocco di script verranno passati i dati della riga come hashtable nella variabile $EventData. Il blocco di script deve restituire una hashtable di stili CSS da applicare alla riga.

#### Esempio 13: ordinamento predefinito

```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
```

Imposti la direzione e la colonna di ordinamento predefinite.

#### Esempio 14: stato iniziale

```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
```

Imposti lo stato iniziale della tabella. Questo può essere utilizzato per impostare l'indice di pagina, la dimensione di pagina, i filtri e la colonna di ordinamento.

#### Esempio 15: colorazione delle righe

```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 }
}
```

Utilizzi OnRowStyle per applicare uno stile alle righe in base ai dati della riga.


---

# 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/it/comandi-powershell/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.
