From 93da54e748f0cf1ede1dc85192bb91eee2666dc7 Mon Sep 17 00:00:00 2001 From: David Matejka Date: Wed, 24 Apr 2024 11:27:20 +0200 Subject: [PATCH] fix(react-datagrid-ui): fix disabled sorting --- .../src/rendering/DataGridHeaderCell.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/react-datagrid-ui/src/rendering/DataGridHeaderCell.tsx b/packages/react-datagrid-ui/src/rendering/DataGridHeaderCell.tsx index fd1bbe15f..e4f6bf6c3 100644 --- a/packages/react-datagrid-ui/src/rendering/DataGridHeaderCell.tsx +++ b/packages/react-datagrid-ui/src/rendering/DataGridHeaderCell.tsx @@ -22,7 +22,7 @@ export type DataGridHeaderCellProps = export function DataGridHeaderCell(props: DataGridHeaderCellProps): ReactElement { const { columnKey, - column: { header, headerJustification, justification, shrunk, ascOrderIcon, descOrderIcon }, + column: { header, headerJustification, justification, shrunk, ascOrderIcon, descOrderIcon, enableOrdering }, } = props const orderDirections = useDataViewSortingState().directions const { setOrderBy } = useDataViewSortingMethods() @@ -36,7 +36,12 @@ export function DataGridHeaderCell(props: DataGridHeaderCellProps): ReactElement return ( - setOrderBy(columnKey, 'next', e.ctrlKey || e.metaKey)} style={{ cursor: 'pointer' }}> + { + if (enableOrdering === false) { + return + } + return setOrderBy(columnKey, 'next', e.ctrlKey || e.metaKey) + }} style={{ cursor: 'pointer' }}> {header}   {orderState &&