UDTable Sort a column descending by default

Hi,

Is there a way to set a column descending by default in a UDTable?
Also, my table is dynamically displayed by the user input some data first. However, when I first time loading the page, it always complains about the table because the input is not there yet. Is there a way to not display the table until the user inputs data?

Thanks so much!

Here is my code:
New-UDTextbox -Id ‘pc’ -Placeholder ‘Machine Name’
New-UDElement -tag ‘div’ -attributes @{
style = @{
height = ‘10px’
}
}
New-UDSingleSelector -Id “list” -options {
@{ value = “AppEnforce.log”; label = “Application Deployment” },
@{ value = “AppDiscovery.log”; label = “Application Detection” },
@{ value = “UpdatesDeployment.log”; label = “Patching Deployment” },
@{ value = “WUAHandler.log”; label = “WSUS Agent Health” },
@{ value = “DataTransferService.log”; label = “Data Transfer Service” },
@{ value = “ClientLocation.log”; label = “Client Location” },
@{ value = “LocationServices.log”; label = “Location Service” },
@{ value = “smsts.log”; label = “Task Sequence” }
}

New-UDElement -tag ‘div’ -attributes @{
style = @{
height = ‘10px’
}
}
New-UDButton -OnClick {
$UDElement = Get-UDElement -id “list”
$session:list=$UDElement.Attributes.selectedOption.value
$session:pc = (Get-UDElement -Id ‘pc’).value
Show-UDToast -Message “You have selected $session:list on $session:pc, it will take a few minutes to get the result.” -Duration 5000
Sync-UDElement -Id ‘table’
} -Text “Confirm”

New-UDElement -tag ‘div’ -attributes @{
style = @{
height = ‘10px’
}
}

New-UDDynamic -Id ‘table’ -Content {
$path = “\$session:pc\C$\Windows\CCM\logs$Session:list”
$result = “$(Get-Content $path -Raw | ForEach-Object { $_ -replace ‘<![LOG[’, ‘’ } | ForEach-Object { $_ -replace ‘]LOG]!>(.*)’, ‘
’ })”

$data = Get-Content -Path $path | %{
            $_ -match '\<\!\[LOG\[(?<Message>.*)?\]LOG\]\!\>\<time=\"(?<Time>.+)(?<TZAdjust>[+|-])(?<TZOffset>\d{2,3})\"\s+date=\"(?<Date>.+)?\"\s+component=\"(?<Component>.+)?\"\s+context="(?<Context>.*)?\"\s+type=\"(?<Type>\d)?\"\s+thread=\"(?<TID>\d+)?\"\s+file=\"(?<Reference>.+)?\"\>' | Out-Null
            [pscustomobject]@{
                UTCTime = [datetime]::ParseExact($("$($matches.date) $($matches.time)$($matches.TZAdjust)$($matches.TZOffset/60)"),"MM-dd-yyyy HH:mm:ss.fffz", $null, "AdjustToUniversal")
                LocalTime = [datetime]::ParseExact($("$($matches.date) $($matches.time)"),"MM-dd-yyyy HH:mm:ss.fff", $null)
                Message = $matches.message
            }
        }

New-UDTable -Data $data -ShowSort
    }

You can use -DefaultSortDirection on New-UDTable to adjust that.

As for the error popup, that has been resolved and will be included in 2.3.0.