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 da9c04abef
commit fdfc333172
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 => {