Skip to content

Commit

Permalink
fix: resolve sorting issues in drilldown table
Browse files Browse the repository at this point in the history
  • Loading branch information
UmakanthKaspa committed Dec 21, 2024
1 parent a96593d commit 270b811
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions frontend/src2/charts/components/DrillDown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import DataTable from '../../components/DataTable.vue'
import { Query } from '../../query/query'
import { Operation, QueryResult, QueryResultColumn, QueryResultRow } from '../../types/query.types'
import { getDrillDownQuery } from '../helpers'
import { column } from '../../query/helpers'
const props = defineProps<{
chart: {
Expand All @@ -17,6 +18,7 @@ const props = defineProps<{
const showDrillDownResults = ref(false)
const drillDownQuery = ref<Query | null>(null)
const sortOrder = ref<Record<string, 'asc' | 'desc'>>({})
watch(
() => props.row || props.column,
Expand All @@ -42,6 +44,21 @@ watch(
},
{ immediate: true, deep: true }
)
function onSort(newSortOrder: Record<string, 'asc' | 'desc'>) {
sortOrder.value = newSortOrder
if (drillDownQuery.value) {
Object.entries(newSortOrder).forEach(([columnName, direction]) => {
drillDownQuery.value?.addOrderBy({
column: column(columnName),
direction,
})
})
drillDownQuery.value.execute()
}
}
</script>

<template>
Expand All @@ -65,6 +82,8 @@ watch(
:enable-pagination="true"
:show-column-totals="true"
:show-filter-row="true"
:sort-order="sortOrder"
@sort="onSort"
:on-export="drillDownQuery ? drillDownQuery.downloadResults : undefined"
>
<template #footer-left>
Expand Down

0 comments on commit 270b811

Please sign in to comment.