New-UDTable
Synopsis
Creates a table.
Syntax
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>]Description
Creates a table. Tables are used to show both static and dynamic data. You can define columns and data to show within the table. The columns can be used to render custom components based on row data. You can also enable paging, filtering, sorting and even server-side processing.
Parameters
-Id
The ID of the component. It defaults to a random GUID.
Required? false
Position? named
Default value [Guid]::NewGuid().ToString()
Accept pipeline input? false
Aliases
Accept wildcard characters? false-Title
The title to show at the top of the table's card.
-Data <Object[]>
The data to put into the table.
-LoadRows
When using dynamic tables, this script block is called. The $Body parameter will contain a hashtable the following options:
filters: @() orderBy: string orderDirection: string page: int pageSize: int properties: @() search: string totalCount: int
You can use these values to perform server-side processing, like SQL queries, to improve the performance of large grids.
After processing the data with these values, output the data via Out-UDTableData.
-Columns <Hashtable[]>
Defines the columns to show within the table. Use New-UDTableColumn to define these columns. If this parameter isn't specified, the properties of the data that you pass in will become the columns.
-OnRowSelection
A script block to call when a row is selected. $EventData will contain the selected rows.
-ShowSort
Whether to show sort controls on columns
-ShowFilter
Whether to show filter controls on columns
-ShowSearch
Whether to show full table search
-Dense
Reduces the white-space used within the table.
-ShowExport
Whether to show the export button.
-StickyHeader
Makes the header sticky.
-PageSize
The default page size.
-PageSizeOptions <Int32[]>
An array of available page size options.
-PaginationLocation
Where to show the pagination controls. Valid values are top, bottom, or both. Defaults to bottom.
-ShowSelection
Whether to allow selection within the table.
-ShowPagination
Whether to show pagination controls.
-Padding
-Size
The size of the table. Defaults to medium. Valid values are medium and small.
-TextOption
Customizations to standard text within the table. Use New-UDTextOption to create the text options.
-ExportOption <String[]>
An array of export options.
-OnExport
A script block used to customize how the export is performed.
-DisablePageSizeAll
Removes the All option from page size options.
-DefaultSortDirection
The default sort direction.
-HideToggleAllRowsSelected
Hides the toggle all rows selected button.
-DisableMultiSelect
Disables multi-select.
-DisableSortRemove
Removes the sort option for unsorted columns. Columns will always be ascending or descending.
-Icon
Sets an icon next to the title. Use New-UDIcon to create the icon.
-ClassName
A CSS class to apply to the table.
-ShowRefresh
Whether to show the refresh button.
-ToolbarContent
Custom content to show in the toolbar.
-OnRowExpand
A script block to call when a row is expanded. The $EventData variable will contain the row data.
-MaxHeight
-AutoRefresh
Reloads the table on an interval when -LoadRows is being used.
-AutoRefreshInterval
The interval to reload data when AutoRefresh is specified.
-Language
The language. Primarily used for Date and Time filters.
-RemoveCard
-OnRowStyle
A script block to call to style rows. The $EventData variable will contain the row data.
-HeaderStyle
A hashtable of styles to apply to the header.
-InitialState
Common parameters
This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters.
Outputs
Examples
Example 1: Basic Table
Creates a static table whether the columns of the table are the properties of the data specified.
Example 2: Columns
Creates a table where there are custom columns defined for that table.
Example 3: Render
Creates a table where the columns are rendered with custom content.
Example 4: Column Width
Set custom column width
Example 5: Column Filter
Columns filters for a table
Example 6: Column Search
Columns can be included in the search
Example 7: Server-side processing
Server-side processing is useful for large data sets that should not be loaded into the browser.
Example 8: Paging
Paging can be enabled by setting the -Paging parameter to $true. The default page size is 10.
Example 9: Row Expansion
Row expansion can be enabled by setting the -OnRowExpand parameter to a scriptblock. The scriptblock will be passed the row data as a hashtable in the $EventData variable.
Example 10: Export
Export table data with the -Export parameter. You can configure which columns are included in the export by setting the -IncludeInExport parameter on the column. Use -Hidden to hide a column from the table but include it in the export.
Example 11: Text Options
Text options can be used to customize the text in the table.
Example 12: Row Styling
You can style rows by using the -OnRowStyle parameter. The script block will be passed the row data as a hashtable in the $EventData variable. The script block should return a hashtable of CSS styles to apply to the row.
Example 13: Default Sort
Set the default sort direction and column.
Example 14: Initial state
Set the initial state of the table. This can be used to set the page index, page size, filters, and order by column.
Example 15: Row coloring
Use OnRowStyle to style rows based on the row data.
Last updated
Was this helpful?