From 698db1a6e6bbe0c39b1504ad790debe7238b97dc Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sun, 5 Jun 2022 13:23:00 -0700 Subject: [PATCH] docs(data-table): add "Programmatic sorting" example --- docs/src/pages/components/DataTable.svx | 12 +++ .../DataTableProgrammaticSorting.svelte | 97 +++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 docs/src/pages/framed/DataTable/DataTableProgrammaticSorting.svelte diff --git a/docs/src/pages/components/DataTable.svx b/docs/src/pages/components/DataTable.svx index 52714f80..2c130b56 100644 --- a/docs/src/pages/components/DataTable.svx +++ b/docs/src/pages/components/DataTable.svx @@ -1075,6 +1075,18 @@ and then limit displayed content by using `pageSize` and `page` props, which are ]}" /> +### Programmatic sorting + +Use the reactive `sortKey` and `sortDirection` props for programmatic sorting. + +By default, the table is not sorted by a specific key. The `sortKey` value must be a valid `key` specified in the `headers` object. + +Possible values for `sortDirection` include `"none"` or `"ascending"` or `"descending"`. + +Setting `sortKey` to `null` and `sortDirection` to `"none"` should reset the table rows to their initial order. + + + ### Empty column with overflow menu Some use cases require an empty column in the table body without a corresponding table header. diff --git a/docs/src/pages/framed/DataTable/DataTableProgrammaticSorting.svelte b/docs/src/pages/framed/DataTable/DataTableProgrammaticSorting.svelte new file mode 100644 index 00000000..c86e548f --- /dev/null +++ b/docs/src/pages/framed/DataTable/DataTableProgrammaticSorting.svelte @@ -0,0 +1,97 @@ + + + + + + + + +