Closed jasonrush closed 3 years ago
Looking at this a bit more, I think the solution would be to convert $DefaultSortOrder from [string]
to [string[]]
, and within the foreach()
loops create some kind of localized $sort
variable. And at this point I've put in enough effort I should just create a PR...
Additional note: From reviewing this chunk of code, I'd imagine lines 714 and 722 (if ($Column -ne - 1) {
) should be -1
and not - 1
with a space?
I am not sure if we should do it this way:
I'm trying to understand the difference between the current solution and the solution from the first link.
Yes, this is a bug (-1). Most likely introduce while formatting 🙀
Ok, going thru the implementation. By default when you use DefaultSortColumn it will always sort it according to DefaultSortOrder. If there are 5 columns to sort on, It will have to be either all ascending or all descending.
There are 2 choices:
New-TableColumnOption
and allow to define it per columnMaybe even have both done.
I've thrown together a PR (https://github.com/EvotecIT/PSWriteHTML/pull/242) that I think should fix it in a non-breaking way (backwards compatible, but makes reasonable enough sense). Haven't actually run/tested it yet.
I'll take a look tomorrow - my brain is shutting down. Thank you for your effort.
No, thank you for the awesome module! I've only dabbled with it a couple times, but it's fantastic to work with both on the coding side and the outputs.
I am trying to create a custom ticketing dashboard, and am running into an issue. I would like to sort first by priority of tickets (high = 1/med = 2/low = 3) and then by ticket ID (larger means newer) so I see high priority tickets first, then newest to oldest. Problem is that means Priority should be sorting Descending (1,2,3) but ID should be sorting Ascending (3,2,1). I've verified I can specify multiple sort columns (int or string arrays depending on specifying column indexes or names) via arrays, but I can only specify one way to sort the columns. Is there any solution/recommendation on how I might be able to do this as-is, or is this a limitation to the current implementation?
https://github.com/EvotecIT/PSWriteHTML/blob/e62d662b1df9bef11c95cd3e8656bae0ef5b051e/Public/New-HTMLTable.ps1#L31-L33
Here's an example of what I'm after (sorting by PRI descending, then ID ascending):