Single field sorting
Use sort-by
and sort-type
to determine the initial sorting field and sorting type ('asc' or 'desc').
Set sortable
property to true in a header items to make the corresponding columns sortable.
Example
<template>
<EasyDataTable
:headers="headers"
:items="items"
:sort-by="weight"
:sort-type="desc"
/>
</template>
<script lang="ts" setup>
const sortBy = "weight";
const sortType = "desc";
const headers: Header[] = [
{ text: "WEIGHT (lbs)", value: "weight", sortable: true},
...
];
...
</script>
PLAYER | TEAM | NUMBER | POSITION | HEIGHT | WEIGHT (lbs) | LAST ATTENDED | COUNTRY |
---|---|---|---|---|---|---|---|
Lebron James | LAL | 6 | F | 6-9 | 250 | St. Vincent-St. Mary HS (OH) | USA |
Giannis Antetokounmpo | MIL | 34 | F | 6-11 | 242 | Filathlitikos | Greece |
Kevin Durant | BKN | 7 | F | 6-10 | 240 | Texas-Austin | USA |
Stephen Curry | GSW | 30 | G | 6-2 | 185 | Davidson | USA |