UniversalDashboard/UniversalDashboard.Community/poshud/pages/data-display/table.ps1
New-ComponentPage -Title 'Table' -Description 'Tables display sets of data. They can be fully customized.' -SecondDescription "Tables display information in a way that’s easy to scan, so that users can look for patterns and insights. They can be embedded in primary content, such as cards." -Content { New-Example -Title 'Simple Table' -Description 'A simple example with no frills. Table columns are defined from the data.' -Example { $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 } New-Example -Title 'Table with Custom Columns' -Description 'Define custom columns for your table.' -Example { $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 -Id 'customColumnsTable' -Data $Data -Columns $Columns } New-Example -Title 'Table with Custom Column Rendering' -Description 'Define column rendering. Sorting and exporting still work for the table.' -Example { $Data = @( @{Dessert = 'Frozen yoghurt'; Calories = 1; 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 = 200; Fat = 6.0; Carbs = 24; Protein = 4.0} ) $Columns = @( New-UDTableColumn -Property Dessert -Title Dessert -Render { $Item = $Body | ConvertFrom-Json New-UDButton -Id "btn$($Item.Dessert)" -Text "Click for Dessert!" -OnClick { Show-UDToast -Message $Item.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 -Sort -Export } New-Example -Title 'Table with server-side processing' -Description 'Process data on the server so you can perform paging, filtering, sorting and searching in systems like SQL.' -Example { $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 -Columns $Columns -LoadData { $Query = $Body | ConvertFrom-Json <# Query will contain filters: [] orderBy: undefined orderDirection: "" page: 0 pageSize: 5 properties: (5) ["dessert", "calories", "fat", "carbs", "protein"] search: "" totalCount: 0 #> @( @{Dessert = 'Frozen yoghurt'; Calories = (Get-Random); Fat = 6.0; Carbs = 24; Protein = 4.0} @{Dessert = 'Ice cream sandwich'; Calories = (Get-Random); Fat = 6.0; Carbs = 24; Protein = 4.0} @{Dessert = 'Eclair'; Calories = (Get-Random); Fat = 6.0; Carbs = 24; Protein = 4.0} @{Dessert = 'Cupcake'; Calories = (Get-Random); Fat = 6.0; Carbs = 24; Protein = 4.0} @{Dessert = 'Gingerbread'; Calories = (Get-Random); Fat = 6.0; Carbs = 24; Protein = 4.0} ) | Out-UDTableData -Page 0 -TotalCount 5 -Properties $Query.Properties } } } -Cmdlet "New-UDTable" |