text format selection bug (#10940)

* re introduce dropdown functionality

* on change re draw row heights
This commit is contained in:
marthasharkey 2024-09-02 17:24:01 +01:00 committed by GitHub
parent 4709076061
commit 9e5773a865
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -631,6 +631,7 @@ onMounted(() => {
:columnDefs="columnDefs"
:rowData="rowData"
:defaultColDef="defaultColDef"
:textFormatOption="textFormatterSelected"
@sortOrFilterUpdated="(e) => checkSortAndFilter(e)"
/>
</Suspense>

View File

@ -29,7 +29,8 @@ import type {
GridApi,
RowHeightParams,
} from 'ag-grid-enterprise'
import { type ComponentInstance, reactive, ref, shallowRef } from 'vue'
import { type ComponentInstance, reactive, ref, shallowRef, watch } from 'vue'
import { TextFormatOptions } from '../visualizations/TableVisualization.vue'
const DEFAULT_ROW_HEIGHT = 22
@ -41,6 +42,7 @@ const _props = defineProps<{
components?: Record<string, unknown>
singleClickEdit?: boolean
stopEditingWhenCellsLoseFocus?: boolean
textFormatOption?: TextFormatOptions
}>()
const emit = defineEmits<{
cellEditingStarted: [event: CellEditingStartedEvent]
@ -62,6 +64,9 @@ function onGridReady(event: GridReadyEvent) {
}
function getRowHeight(params: RowHeightParams): number {
if (_props.textFormatOption === TextFormatOptions.Off) {
return DEFAULT_ROW_HEIGHT
}
const rowData = Object.values(params.data)
const textValues = rowData.filter((r): r is string => typeof r === 'string')
@ -80,6 +85,14 @@ function getRowHeight(params: RowHeightParams): number {
return (maxReturnCharsCount + 1) * DEFAULT_ROW_HEIGHT
}
watch(
() => _props.textFormatOption,
() => {
gridApi.value?.redrawRows()
gridApi.value?.resetRowHeights()
},
)
function updateColumnWidths(event: FirstDataRenderedEvent | RowDataUpdatedEvent) {
if (event.columnApi == null) {
console.warn('AG Grid column API does not exist.')