elm-sortable-table
elm-sortable-table copied to clipboard
Allow reversed initial sort
Currently initial sort can be only ascending but in some cases it is useful to have it reverse (e.g. price, date).
Possible solutions are either adding 2nd argument to initialSort
:
initialSort : String -> Bool -> State
initialSort header isReverse =
State header isReverse
or if you want to avoid BC break adding a new initialReversedSort
(or initialSortReversed
):
initialReversedSort : String -> State
initialSort header =
State header True
Please let me know what do you prefer and I will create a PR.
Another possible solution is exposing the State
type constructor, like
module Table exposing
( ...
, State(State)
...
)
And we could get the initial state by
model =
{ ...
, tableState = Table.State "Header" True
...
}
I think you can do this already by defining the column with the decreasingOrIncreasingBy
sorter, no?
I think you can do this already by defining the column with the decreasingOrIncreasingBy sorter, no?
Close, but not quite. The order will be as expected, but the descending/ascending state will be reversed and displayed incorrectly in the UI.
Is there any workaround for enabling this?
@BinaryHexer You can use a fork by adding the following to elm-package.json
:
"dependency-sources": {
"evancz/elm-sortable-table": "http://github.com/determined-ai/elm-sortable-table.git"
},
and the following to package.json
in the dependencies
stanza:
"elm-github-install": "1.6.1",
Note that you will need to run yarn run elm-github-install
before yarn run elm-make
. Finally you should use your own GitHub fork instead of the example one.
@gaul Thanks!
But maybe somebody should start maintaining an alternative version of this on elm-packages, because it seems many PRs are pending on this repository and maybe evanz is too busy (understandably so) to maintain this.