refactor: KsDataGrid - simplify focusRow and rely on AG Grid native Enter navigation
This commit is contained in:
@@ -112,7 +112,6 @@ function onCellValueChanged(event: CellValueChangedEvent): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function onSortChanged(params: { api: { redrawRows: () => void; refreshCells: (options: { force: boolean }) => void } }): void {
|
function onSortChanged(params: { api: { redrawRows: () => void; refreshCells: (options: { force: boolean }) => void } }): void {
|
||||||
params.api.redrawRows()
|
params.api.redrawRows()
|
||||||
}
|
}
|
||||||
@@ -139,25 +138,15 @@ function onGridReady(params: GridReadyEvent): void {
|
|||||||
params.api.sizeColumnsToFit()
|
params.api.sizeColumnsToFit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function focusRow(rowIndex: number, colKey?: string): void {
|
function focusRow(rowIndex: number, colKey?: string): void {
|
||||||
if (!gridApi.value) return
|
if (!gridApi.value) return
|
||||||
const col = colKey || (props.columns[0]?.field ?? '')
|
const col = colKey || (props.columns[0]?.field ?? '')
|
||||||
|
|
||||||
const attempt = () => {
|
|
||||||
if (!gridApi.value) return
|
|
||||||
gridApi.value.ensureIndexVisible(rowIndex)
|
gridApi.value.ensureIndexVisible(rowIndex)
|
||||||
if (col) {
|
if (col) {
|
||||||
gridApi.value.setFocusedCell(rowIndex, col)
|
gridApi.value.setFocusedCell(rowIndex, col)
|
||||||
gridApi.value.startEditingCell({ rowIndex, colKey: col })
|
gridApi.value.startEditingCell({ rowIndex, colKey: col })
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
attempt()
|
|
||||||
setTimeout(attempt, 50)
|
|
||||||
setTimeout(attempt, 150)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function redrawRows(): void {
|
function redrawRows(): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user