From 4a827c2aabd03f992cd60000d0609d62e1e6eeb8 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 29 Sep 2021 10:17:12 +0100 Subject: [PATCH] Fix resetting filters and sorting options when changing tables --- .../backend/DataTable/DataTable.svelte | 29 ++++++++++--------- .../FilterEditor/FilterDrawer.svelte | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte index 7a04783579..64762d5db2 100644 --- a/packages/builder/src/components/backend/DataTable/DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte @@ -14,25 +14,21 @@ import { fetchTableData } from "helpers/fetchTableData" import { Pagination } from "@budibase/bbui" - const search = fetchTableData() let hideAutocolumns = true - let filters $: isUsersTable = $tables.selected?._id === TableNames.USERS - $: title = $tables.selected?.name $: schema = $tables.selected?.schema $: type = $tables.selected?.type $: isInternal = type !== "external" $: id = $tables.selected?._id + $: search = searchTable(id) $: columnOptions = Object.keys($search.schema || {}) - $: fetchTable(id, filters) // Fetches new data whenever the table changes - const fetchTable = (tableId, filters) => { - search.update({ + const searchTable = tableId => { + return fetchTableData({ tableId, schema, - filters, limit: 10, paginate: true, }) @@ -45,14 +41,21 @@ sortOrder: e.detail.order, }) } + + // Fetch data whenever filters change + const onFilter = e => { + search.update({ + filters: e.detail, + }) + }
- (filters = e.detail)} - /> + {#key id} + + {/key} {/if}