Broadcast a sort event from BBUI table, and add prop to disable table sorting of data

This commit is contained in:
Andrew Kingston 2021-09-23 16:08:09 +01:00
parent b5ff5a7f76
commit 05cfd87613
1 changed files with 3 additions and 1 deletions

View File

@ -27,6 +27,7 @@
export let selectedRows = [] export let selectedRows = []
export let editColumnTitle = "Edit" export let editColumnTitle = "Edit"
export let customRenderers = [] export let customRenderers = []
export let disableSorting = false
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -107,7 +108,7 @@
} }
const sortRows = (rows, sortColumn, sortOrder) => { const sortRows = (rows, sortColumn, sortOrder) => {
if (!sortColumn || !sortOrder) { if (!sortColumn || !sortOrder || disableSorting) {
return rows return rows
} }
return rows.slice().sort((a, b) => { return rows.slice().sort((a, b) => {
@ -131,6 +132,7 @@
sortColumn = fieldSchema.name sortColumn = fieldSchema.name
sortOrder = "Descending" sortOrder = "Descending"
} }
dispatch("sort", { column: sortColumn, order: sortOrder })
} }
const getDisplayName = schema => { const getDisplayName = schema => {