You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/pages/components/DataTable.svx
+81Lines changed: 81 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -946,6 +946,87 @@ Set `sortable` to `true` to enable column sorting. Disable sorting on specific c
946
946
]}"
947
947
/>
948
948
949
+
## Sortable (sort always)
950
+
951
+
Sortable columns support three directions: `none` (unsorted, original row order), `ascending`, and `descending`. Clicking a column header cycles through them in order.
952
+
953
+
By default, a third click on a sorted column unsorts it (`none` restores the original row order).
954
+
955
+
Set `sortAlways` to `true` to skip the unsorted state so the column always remains sorted. The first click goes to `ascending`; subsequent clicks alternate between `ascending` and `descending` (no `none`).
956
+
957
+
<DataTable sortable sortAlways
958
+
headers="{[
959
+
{ key: "name", value: "Name" },
960
+
{ key: "protocol", value: "Protocol" },
961
+
{ key: "port", value: "Port" },
962
+
{ key: "rule", value: "Rule" }
963
+
]}"
964
+
rows="{[
965
+
{
966
+
id: "a",
967
+
name: "Load Balancer 3",
968
+
protocol: "HTTP",
969
+
port: 3000,
970
+
rule: "Round robin"
971
+
},
972
+
{
973
+
id: "b",
974
+
name: "Load Balancer 1",
975
+
protocol: "HTTP",
976
+
port: 443,
977
+
rule: "Round robin"
978
+
},
979
+
{
980
+
id: "c",
981
+
name: "Load Balancer 2",
982
+
protocol: "HTTP",
983
+
port: 80,
984
+
rule: "DNS delegation"
985
+
},
986
+
{
987
+
id: "d",
988
+
name: "Load Balancer 6",
989
+
protocol: "HTTP",
990
+
port: 3000,
991
+
rule: "Round robin"
992
+
},
993
+
{
994
+
id: "e",
995
+
name: "Load Balancer 4",
996
+
protocol: "HTTP",
997
+
port: 443,
998
+
rule: "Round robin"
999
+
},
1000
+
{
1001
+
id: "f",
1002
+
name: "Load Balancer 5",
1003
+
protocol: "HTTP",
1004
+
port: 80,
1005
+
rule: "DNS delegation"
1006
+
},
1007
+
]}"
1008
+
/>
1009
+
1010
+
## Sortable (per-column sortAlways)
1011
+
1012
+
Use `sortAlways` on individual headers to control which columns allow unsorting. In this transaction log, the Date column always stays sorted (chronological order is required for audit trails), while Amount and Status can be unsorted.
0 commit comments