<ReactDataGrid />
supports showing row details via expanded rows. In order to enable expanded rows, make sure to specify arowExpandHeight
and the renderRowDetails({ data, rowIndex, ... })
function prop, which will be used to render the details for expanded rows. When enabling row expand, the <ReactDataGrid />
will now have two possible row heights: unexpanded (collapsed) rows will have the height specified by rowHeight
, while expanded rows will have their size specified by rowExpandHeight
.expandedRows
prop (this prop is controlled, see defaultExpandedRows
for uncontrolled version). The value of this prop should be an object - the keys in this object are the ids of the expanded rows, while the value for each key should be true
.expandedRows
can also be true
, which means all rows should be rendered as expanded - however, we still need the ability to specify that some of the rows should be collapsed - this is achieved via collapsedRows
(controlled; see defaultExpandedRows
for uncontrolled alternative).renderRowDetails({ data, rowIndex, ... })
function prop. It is called for you with an object as a first argument - the object has the following properties:data
- the data item corresponding to the current expanded rowrowSelected
- specifies if the current row is selected
rowActive
- specifies if the current row is active
rowId
- the value of the idProperty
for the current row data objecttoggleRowExpand
- you can call this function with no arguments to collapse the current rowdataSource
- a reference to the current dataSource
array that the <ReactDataGrid />
displaysrenderRowDetails
function prop gives the developer access to a lot of information about the row being rendered, which makes it really flexible and easy to use.render
function is called with arguments that contain information about the expanded state of the row, and with functions that can be used to change the row expanded state - see columns.render
for details.multiRowExpand=false
. By default the <ReactDataGrid />
is configured to allow multiple rows to be expanded at the same time.rowExpandColumn
prop on the <ReactDataGrid />
.rowExpandColumn=false
hides the row expand column.rowExpandColumn
can also be an object (a column configuration object), so you can specify custom rowExpandColumn.render
, rowExpandColumn.header
, etc render functions. All properties available for normal columns are also available here.onRowExpand
- called when a single row is expanded. Returning false
from this function will prevent expanding the row.onRowCollapse
- called when a single row is collapsed. Returning false
from this function will prevent collapsing the row.onRowExpandChange
- called when a single row is collapsed or expanded. Returning false
from this function will prevent collapsing or expanding the row.onExpandedRowsChange
- unlike all of the above, this function is called for both single row expand/collapse, as well as for bulk actions, like calling collapseAllRows
or expandAllRows
.expandedRows
or collapsedRows
to control which rows are expanded or collapsed, make sure you update their values as a result of user interaction, which triggers the callback props described above (eg onExpandedRowsChange
).isRowExpandable
function prop, which gives you a lot of flexibility to decide which rows should not be expandable.unexpandableRows
- it's not as flexible as isRowExpandable
, but it can be a bit more performant.<ReactDataGrid />
allows you to control the width of the row details via the rowDetailsWidth
prop."max-viewport-width"
- the width of the row details will be maximum the width of the grid viewport width. When columns take up less space, the row details will be sized to the total width of the columns. If columns don't fit in the grid viewport and horizontal scrollbar is needed, the row details will be still constrained to the width of the grid viewport."min-viewport-width"
- the width of the row details will be minimum the width of the grid viewport width. When columns take up less space, the row details will be sized to fill the grid viewport. If columns don't fit in the grid viewport and horizontal scrollbar is needed, the row details will grow with the total columns width, and will be scrolled together with the grid viewport."viewport-width"
- the width of the row details will be exactly the width of the grid viewport width, no matter the size of grid columns.ScrollContainer
, to have the same scroller as the <ReactDataGrid />
. See the example below for details.<ReactDataGrid />
supports diferent heights for row details by specifying rowExpandHeight({ data })
as a function, in which you will receive data
as a parameter. If you specify the prop as a number, then the heights will be the same for all the row details.