> 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/powershell-commands/new-uddatagrid.md).

# New-UDDataGrid

### Synopsis

Displays data in a table-style grid.

### Syntax

```powershell
New-UDDataGrid [[-Id] <String>] [[-Columns] <Hashtable[]>] [[-LoadRows] <Endpoint>] [[-Height] <String>] [[-AutoHeight] <Boolean>] [-AutoPageSize] [-CheckboxSelection] [-CheckboxSelectionVisibleOnly] [[-ColumnBuffer] <Int32>] [[-ColumnThreshold] <Int32>] [[-Density] <String>] [[-PageSize] <Int32>] [[-RowsPerPageOptions] <Int32[]>] [-ShowPagination] [[-OnSelectionChange] <Endpoint>] [[-Language] <String>] [[-LoadDetailContent] <Endpoint>] [[-DetailHeight] <String>] [[-OnEdit] <Endpoint>] [[-OnExport] <Endpoint>] [-ShowQuickFilter] [[-DefaultSortColumn] <String>] [[-DefaultSortDirection] <String>] [-DisableRowSelectionOnClick] [-HideExport] [[-RowHeight] <Int32>] [[-IdentityColumn] <String>] [-StripedRows] [-HeaderFilters] [-AutoSizeColumns] [[-ExportOptions] <String[]>] [<CommonParameters>]
```

### Description

Displays data in a table-style grid. Provides support for sorting, paging, and filtering of large data sets.

### Parameters

#### -Id

The ID of this data grid.

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

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

An array of column to display in this table.

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

#### -LoadRows

The script block that loads the data for this grid.

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

#### -Height

The static height for this data grid.

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

#### -AutoHeight

Whether to calculate the height of this data grid.

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

    -AutoPageSize [<SwitchParameter>]
        Automatically determines the page size.

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

    -CheckboxSelection [<SwitchParameter>]
        Checkbox selection for rows.

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

    -CheckboxSelectionVisibleOnly [<SwitchParameter>]
        Parameter description

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

#### -ColumnBuffer

Parameter description

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

#### -ColumnThreshold

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

#### -Density

The visible density of the table.

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

#### -PageSize

The default page size.

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

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

An array of page sizes.

```
Required?                    false
Position?                    10
Default value                @(5, 10, 25)
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false

    -ShowPagination [<SwitchParameter>]
        Whether to show Pagination.

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

#### -OnSelectionChange

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

#### -Language

The language to use for text in the data grid.

```
Required?                    false
Position?                    12
Default value                en-US
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -LoadDetailContent

A script block that is called when rows are expanded. $EventData will contain the row's data.

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

#### -DetailHeight

The static height of the detail pane.

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

#### -OnEdit

A script block that is called when the row is edited. $EventData will include the edited data. Return an object to update the data grid row.

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

#### -OnExport

A script block that is called when data is exported.

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

    -ShowQuickFilter [<SwitchParameter>]
        Shows a quick filter (search) box.

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

#### -DefaultSortColumn

The default column to sort by.

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

#### -DefaultSortDirection

The default sort direction.

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

    -DisableRowSelectionOnClick [<SwitchParameter>]
        Disables row selection on click.

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

    -HideExport [<SwitchParameter>]
        Hides the export button.

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

#### -RowHeight

The height of the rows.

```
Required?                    false
Position?                    19
Default value                -1
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -IdentityColumn

The identity column for the data grid.

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

    -StripedRows [<SwitchParameter>]
        Whether to use striped row colors.

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

    -HeaderFilters [<SwitchParameter>]
        Whether to show filters in the column headers.

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

    -AutoSizeColumns [<SwitchParameter>]
        Automatically size columns.

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

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

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

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).
```

### Outputs

\-------------------------- EXAMPLE 1 --------------------------

```
PS >New-UDDataGrid -LoadRows {
PS >     $Data = @(
PS >         @{ Name = 'Adam'; Number = Get-Random}
PS >         @{ Name = 'Tom'; Number = Get-Random}
PS >         @{ Name = 'Sarah'; Number = Get-Random}
PS >     )
PS >     @{
PS >         rows = $Data
PS >         rowCount = $Data.Length
PS >     }
PS > } -Columns @(
PS >     New-UDDataGridColumn -Field 'Name'
PS >     New-UDDataGridColumn -Field 'Number'
PS > ) -Id 'dataGrid1'

Basic data grid|Creates a basic data grid with columns.




-------------------------- EXAMPLE 2 --------------------------

PS >New-UDDataGrid -LoadRows {
PS >     $Data = 1..1000 | ForEach-Object {
PS >         @{ Name = "User$($_)"; Number = Get-Random }
PS >     }
PS >     Out-UDDataGridData -Data $Data -Total $Data.Length -Context $EventData
PS > } -Columns @(
PS >     New-UDDataGridColumn -Field 'Name'
PS >     New-UDDataGridColumn -Field 'Number'
PS > ) -Pagination -Id 'dataGrid2'

Out-UDDataGridData|Adds support for filtering, sorting, and paging.




-------------------------- EXAMPLE 3 --------------------------

PS >New-UDDataGrid -LoadRows {
PS >     $Data = 1..100 | % {
PS >         @{ Name = 'Adam'; Number = Get-Random}
PS >     }
PS >     Out-UDDataGridData -Data $Data -Total $Data.Length -Context $EventData
PS >
PS > } -Columns @(
PS >     New-UDDataGridColumn -Field 'Name' -Render {
PS >         New-UDAlert -Text $EventData.Name -Dense
PS >     }
PS >     New-UDDataGridColumn -Field 'Number'
PS > ) -Pagination -Id 'dataGrid3'

Render|Adds support for custom rendering of columns.




-------------------------- EXAMPLE 4 --------------------------

PS >New-UDDataGrid -LoadRows {
PS >     $Data = @(
PS >         @{ Name = 'Adam'; Number = Get-Random }
PS >         @{ Name = 'Tom'; Number = Get-Random }
PS >         @{ Name = 'Sarah'; Number = Get-Random }
PS >     )
PS >     @{
PS >         rows     = $Data
PS >         rowCount = $Data.Length
PS >     }
PS > } -Columns @(
PS >     New-UDDataGridColumn -Field 'Name'
PS >     New-UDDataGridColumn -Field 'Number'
PS > ) -LoadDetailContent {
PS >     New-UDAlert -Text $EventData.row.Name
PS > } -Id 'dataGrid4'

Detailed Content|Adds support for detailed content.




-------------------------- EXAMPLE 5 --------------------------

PS >$Cache:Data = @(
PS >     @{ Name = 'Adam'; number = Get-Random }
PS >     @{ Name = 'Tom'; number = Get-Random }
PS >     @{ Name = 'Sarah'; number = Get-Random }
PS > )
PS > New-UDDataGrid -LoadRows {
PS >     $Cache:Data| Out-UDDataGridData -Context $EventData -TotalRows $Cache:Data.Length
PS > } -Columns @(
PS >     New-UDDataGridColumn -Field name -Render {
PS >         New-UDButton -Text $EventData.number
PS >     }
PS >     New-UDDataGridColumn -Field number -Editable
PS > ) -AutoHeight $true -OnEdit {
PS >     $Cache:Data | Where-Object { $_.Name -eq $EventData.NewRow.Name } | ForEach-Object {
PS >         $_.Number = $EventData.NewRow.Number
PS >     }
PS > } -Id 'datagrid5'

Editing|Adds support for editing rows.




-------------------------- EXAMPLE 6 --------------------------

PS >New-UDDataGrid -LoadRows {
PS >     $Data = @(
PS >         @{ Name = 'Adam'; number = Get-Random }
PS >         @{ Name = 'Tom'; number = Get-Random }
PS >         @{ Name = 'Sarah'; number = Get-Random }
PS >     )
PS >     @{
PS >         rows     = $Data
PS >         rowCount = $Data.Length
PS >     }
PS > } -Columns @(
PS >     New-UDDataGridColumn -Field 'Name' -HeaderName 'A Name' -Flex 1 -HeaderAlign 'center' -Align 'center' -DisableColumnMenu
PS >     New-UDDataGridColumn -Field 'Number' -HeaderName 'A Number' -Flex 1 -HeaderAlign 'right' -Align 'right' -DisableColumnMenu
PS > ) -Id 'dataGrid6'

Column Options|




-------------------------- EXAMPLE 7 --------------------------

PS >New-UDDataGrid -LoadRows {
PS >     $Data = @(
PS >         @{ Id = 1; Name = 'Adam'; number = Get-Random }
PS >         @{ Id = 2; Name = 'Tom'; number = Get-Random }
PS >         @{ Id = 3; Name = 'Sarah'; number = Get-Random }
PS >     )
PS >     @{
PS >         rows     = $Data
PS >         rowCount = $Data.Length
PS >     }
PS > } -Columns @(
PS >     New-UDDataGridColumn -Field 'Name' -HeaderName 'A Name' -Flex 1 -HeaderAlign 'center' -Align 'center' -DisableColumnMenu
PS >     New-UDDataGridColumn -Field 'Number' -HeaderName 'A Number' -Flex 1 -HeaderAlign 'right' -Align 'right' -DisableColumnMenu
PS > ) -Id 'dataGrid7' -CheckboxSelection -CheckboxSelectionVisibleOnly -DisableRowSelectionOnClick

Selection| Adds support for row selection.
```


---

# 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/powershell-commands/new-uddatagrid.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.
