Master Detail

The Vue DataGrid that Infinite Table offers has native support for master-detail rows.
The single most important property for the master-detail DataGrid configuration is the rowDetailRenderer function prop - which makes the DataGrid be considered master-detail.
In addition, make sure you have a column with the renderRowDetailIcon: true flag set. columns.renderRowDetailIcon on a column makes the column display the row detail expand icon.
The row detail in the DataGrid can contain another DataGrid or any other custom content.
It's very imporant that the rowDetailRenderer function prop you pass into <InfiniteTable /> is stable and doesn't change on every render. So make sure you pass a reference to the same function every time - except of course if you want the row detail to change based on some other state.
The rowDetailRenderer function returns the content of the row detail as VNodes created with h() - for a detail DataGrid, that is h(DataSource, { ... }, () => h(InfiniteTable, { ... })). Define the function in <script setup>, not inline in the template, so the same function is passed on every render.
#
Basic master detail DataGrid example
This example shows a master DataGrid with cities & countries.
The details for each city shows a DataGrid with developers in that city.
The detail DataGrid is configured with remote sorting.
open
loading demo…
If you want to use a component instead of the rowDetailRenderer function, you can use the components.RowDetail property. This works similarly and makes the DataGrid be considered master-detail. Inside the component, call the useGetMasterDetailContextForVue composable in setup - it returns a getter function, and getter()?.masterRowInfo is the master row information.

Loading the Detail DataSource#

When master-detail is configured and the row detail renders a DataGrid, the data function for the detail <DataSource /> will be called with the masterRowInfo as a property available in the object passed as argument.
Loading the detail DataGrid data
const detailDataFn: DataSourceData<Developer> = ({
  masterRowInfo,
  sortInfo,
  // ...
}) => {

  return Promise.resolve([/* ... */])
}

// the detail DataSource, as rendered by the `rowDetailRenderer` function
h(DataSource, { data: detailDataFn, primaryKey: 'id' }, () => [
  /* ... */
]);
You can see the live example above for more details.

Rendering a detail DataGrid#

Using the rowDetailRenderer prop, you can render any custom content for the row details.
The content doesn't need to include Infinite Table.
You can, however, render an Infinite Table Vue DataGrid, at any level of nesting inside the row detail content.
#
Master detail with custom content & DataGrid
In this example, the row detail contains custom content, along with another Infinite Table DataGrid. You can nest a child DataGrid inside the row details at any level of nesting.
open
loading demo…

Configuring the master-detail height#

In order to configure the height of the row details, you can use the rowDetailHeight prop.
Configuring the row detail height
<InfiniteTable :columns="masterColumns" :rowDetailHeight="500" :rowDetailRenderer="renderDetail" />
The default value for the rowDetailHeight is 300 px.
rowDetailHeight can be one of the following:
  • number - the height in pixels
  • string - the name of a CSS variable that configures the height - eg: --master-detail-height
  • (rowInfo) => number - a function that can return a different height for each row. The sole argument is the rowInfo object.
#
Master detail DataGrid with custom height for row details
This master-detail DataGrid is configured with a custom rowDetailHeight of 200px.
open
loading demo…

Conditional row details#

Not all rows in a DataGrid need to have details. To configure which rows have details, you can use the isRowDetailEnabled function prop.
Using conditional row details
const isRowDetailEnabled = (rowInfo: InfiniteTableRowInfo<City>) =>
  rowInfo.data?.cityName?.includes('i') ?? false;

// <InfiniteTable
//   :columns="masterColumns"
//   :rowDetailHeight="500"
//   :rowDetailRenderer="renderDetail"
//   :isRowDetailEnabled="isRowDetailEnabled"
// />
The isRowDetailEnabled function prop is called with the rowInfo object and is expected to return a boolean value.
#
Master detail DataGrid with conditional details
This example shows a master DataGrid with cities & countries.
Not all rows have details - every other row is configured without details via the isRowDetailEnabled function prop.
open
loading demo…