> 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

New-UDDataGrid displays tabular data in PowerShell Universal with built-in sorting, paging, filtering, and row selection for large datasets.

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

Automatically determines the page size.

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

#### -CheckboxSelection

Checkbox selection for rows.

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

#### -CheckboxSelectionVisibleOnly

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

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

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

Disables row selection on click.

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

#### -HideExport

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

Whether to use striped row colors.

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

#### -HeaderFilters

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

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

#### Common parameters

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

### Examples

#### Example 1: Basic data grid

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

Creates a basic data grid with columns.

#### Example 2

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

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

#### Example 3: Render

```powershell
New-UDDataGrid -LoadRows {
    $Data = 1..100 | % {
        @{ Name = 'Adam'; Number = Get-Random}
    }
    Out-UDDataGridData -Data $Data -Total $Data.Length -Context $EventData

} -Columns @(
    New-UDDataGridColumn -Field 'Name' -Render {
        New-UDAlert -Text $EventData.Name -Dense
    }
    New-UDDataGridColumn -Field 'Number'
) -Pagination -Id 'dataGrid3'
```

Adds support for custom rendering of columns.

#### Example 4: Detailed Content

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

Adds support for detailed content.

#### Example 5: Editing

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

Adds support for editing rows.

#### Example 6

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

Column Options|

#### Example 7: Selection

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

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.
