diff --git a/CHANGELOG.md b/CHANGELOG.md index 23bf1b2662d..233c1aa843c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ - Fixed `EuiErrorBoundary` error message not showing in non-Chromium browsers ([#4324](https://github.com/elastic/eui/pull/4324)) - Fixed `EuiToolTip` closing during initial positioning period ([#4327](https://github.com/elastic/eui/pull/4327)) - Added `!default` to SASS variables of `EuiCollapsibleNav` ([#4335](https://github.com/elastic/eui/pull/4335)) +- Fixed `EuiDataGrid` column property `displayAsText`. Column headers prefer `displayAsText` over `id`; `display` still takes precedence. If provided, the filter in the sort-popover will search against `displayAsText` instead of `id`. ([#4351](https://github.com/elastic/eui/pull/4351)) + **Theme: Amsterdam** diff --git a/src-docs/src/views/datagrid/datagrid.js b/src-docs/src/views/datagrid/datagrid.js index 7024a855e75..c4acd4628c5 100644 --- a/src-docs/src/views/datagrid/datagrid.js +++ b/src-docs/src/views/datagrid/datagrid.js @@ -84,6 +84,8 @@ const columns = [ }, { id: 'email', + displayAsText: 'Email address', + initialWidth: 130, cellActions: [ ({ rowIndex, columnId, Component }) => { const data = useContext(DataContext); @@ -100,9 +102,11 @@ const columns = [ }, { id: 'location', + displayAsText: 'Location', }, { id: 'account', + displayAsText: 'Account', actions: { showHide: { label: 'Custom hide label' }, showMoveLeft: false, @@ -140,19 +144,23 @@ const columns = [ }, { id: 'date', + displayAsText: 'Date', defaultSortDirection: 'desc', }, { id: 'amount', + displayAsText: 'Amount', }, { id: 'phone', + displayAsText: 'Phone', isSortable: false, }, { id: 'version', + displayAsText: 'Version', defaultSortDirection: 'desc', - initialWidth: 65, + initialWidth: 70, isResizable: false, actions: false, }, diff --git a/src/components/datagrid/column_selector.tsx b/src/components/datagrid/column_selector.tsx index 5e134477fe4..4b1f0a2c80e 100644 --- a/src/components/datagrid/column_selector.tsx +++ b/src/components/datagrid/column_selector.tsx @@ -117,7 +117,10 @@ export const useDataGridColumnSelector = ( }); const filteredColumns = sortedColumns.filter( - (id) => id.toLowerCase().indexOf(columnSearchText.toLowerCase()) !== -1 + (id) => + (displayValues[id] || id) + .toLowerCase() + .indexOf(columnSearchText.toLowerCase()) !== -1 ); const isDragEnabled = allowColumnReorder && columnSearchText.length === 0; // only allow drag-and-drop when not filtering columns diff --git a/src/components/datagrid/data_grid_header_cell.tsx b/src/components/datagrid/data_grid_header_cell.tsx index 2ed6fe317fd..23977ed6e24 100644 --- a/src/components/datagrid/data_grid_header_cell.tsx +++ b/src/components/datagrid/data_grid_header_cell.tsx @@ -70,7 +70,7 @@ export const EuiDataGridHeaderCell: FunctionComponent )} {!showColumnActions ? ( -
{display || id}
+
+ {display || displayAsText || id} +
) : (