Table sort defaulting to ascending in first column

Product: PowerShell Universal
Version: 1.4.9

My data coming out of SQL is descending by date. When rendered by the table it is ascending by date. If I export the data it is in the correct order. It makes no difference if I remove -DefaultSortColumn from Date.

$Columns = @(
	New-UDTableColumn -Property 'CreatedDate' -Title 'Date' -IncludeInExport -IncludeInSearch -DefaultSortColumn 
	New-UDTableColumn -Property 'ScriptSource' - -Title 'Script Source' -IncludeInSearch -IncludeInExport -ShowFilter
	New-UDTableColumn -Property 'Status' -Title 'Status' -IncludeInSearch -IncludeInExport -ShowFilter
	New-UDTableColumn -Property 'ServerName' -Title 'Server Name' -IncludeInSearch -IncludeInExport -ShowFilter
	New-UDTableColumn -Property 'Message' -Title 'Message'-IncludeInSearch -IncludeInExport
)

$SQL = "SELECT Created_Date, ScriptSource,Status,ServerName,Message FROM ScriptLogging WHERE Created_date >= DATEADD(day, -7, GETDATE()) ORDER BY Created_Date DESC;"

$Data = Invoke-Sqlcmd -Query $sql -ServerInstance $ENV:DBServer -Username $ENV:SQLUsername -Password $ENV:SQLPassword -Database $ENV:DBName -EncryptConnection | ForEach-Object {
	@{
		CreatedDate = ($_.Created_Date).AddHours(-7);
		ScriptSource = $_.ScriptSource;
		Status = $_.Status;
		ServerName = $_.ServerName;
		Message = $_.Message
	}
}

New-UDTable -Title "Last 7 Days of Logs" -Columns $Columns -Data $Data -ShowPagination -Dense -Export -ShowSearch -PageSize 10

Thanks,
Jeremy

i opened an issue for that and it will be fixed in the upcoming release

1 Like

It is good to know I wasn’t going crazy!

:+1:

you don’t i am :slight_smile:

1 Like