[OuiDataGrid][Research] Understand how rowHeightsOptions allows configuring row heights #1216
Labels
datagrid
documentation
Improvements or additions to documentation
Research
An open request for eng to research one or more topics
The OuiDataGrid component from the OUI framework implements
rowHeightsOptions
to enable adjustable row heights, particularly for handling multiline cell content. This functionality is achieved through a combination of React components and utility classes. Here's a breakdown of how it works:Related Classes and Components
RowHeightUtils Class
Purpose: This utility class is crucial for calculating row heights based on various criteria like line count, padding, line height, etc.
Key Methods:
computeStylesForGridCell(gridStyles)
: Determines the styles for grid cells. It uses a fake cell, applies styles, and appends it to the document to compute the effective styles (padding, line height).calculateHeightForLineCount(lineCount)
: Calculates the height of a cell based on the number of lines it should display.getCalculatedHeight(heightOption, defaultHeight)
: Determines the calculated height of a row based on the provided height option (could be a line count or specific height) and a default height.OuiDataGrid Component
RowHeightUtils
: The grid component imports and usesRowHeightUtils
. It callscomputeStylesForGridCell
to initialize the styles based on the grid's current styles.rowHeightUtils
,rowHeightsOptions
, andgridStyles
to the OuiDataGridBody.OuiDataGridBody Component
getRowHeight
(a method that utilizes RowHeightUtils) to determine the height of each row.rowHeightsOptions
passed to the component.OuiDataGridCell Component
OuiDataGridCellContent
component, used withinOuiDataGridCell
, renders the actual cell content. It applies styles calculated for the row height, controlling how content is displayed (e.g., number of lines, overflow handling).OuiDataGridCellContent Component
Overall Flow
The text was updated successfully, but these errors were encountered: