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, + }) + }