Skip to content

DetailsList column sorts formatted numeric values lexicographically: workaround + feature request #389

@eccountable

Description

@eccountable

First, DetailsList is awesome - thanks! Here is a feature request:
I am using Power Automate and custom FetchXML on Dataverse to get my data into a collection in my Canvas Page.
My collection has many columns of numbers that range from 0-15 with up to 3 decimal places. The client wants to see all 3 decimal places and right justified. The only way to do that (that I have found works) is to convert the displayed data using the Right("_" & Text(,"#0.000"),6) function, however, that breaks the column sorting feature, which treats all column values as text, so numeric values sort lexicographically (e.g., “1”, “10”, “2”, “20”) rather than numerically (and still left justified because the string appears trimmed).

My workaround is to add a 'formatted' column (using the above expression) for each numeric column. For example, if I have a numeric column name of "ecc_25", then I AddColumns(, ecc_25_formatted, Right("" & Text(ecc_25,"#0.000"),6)) so now there is one numeric column in the collection that can be sorted correctly, and a formatted version that I added to the fields of the DetailsList control. All my values are a link, so they appear to be underlined when rendered, and my "" prefix is not obvious to the user.

Then in the DetailsList OnChange event I have this:
If( Self.EventName = "Sort", UpdateContext( { ctxSortCol: If(("formatted" in Self.SortEventColumn), Left(Self.SortEventColumn,6), Self.SortEventColumn), ctxSortAsc: If(Self.SortEventDirection='PowerCAT.FluentDetailsList.SortEventDirection'.Ascending,true,false) } ) );

Note the ctxSortCol is expecting the name of the sorting column as a string, so I trim off the "_formatted" part of the column name and the DetailsList will take care of the sorting correctly.

What would save a lot coding is a Text format property added to each column (defined in columns_Items) and a justification property (left/right/center).

Thanks for your consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions