Saltar al contenido

🎉 v5 is out! Head to the documentation to get started.

Data Grid - Layout

The data grid offers multiple layout mode.

By default, the grid has no intrinsic dimensions. It occupies the space its parent leaves.

⚠️ When using % (percentage) for your height or width. You need to make sure the container you are putting the grid into also has an intrinsic dimension. The browsers fit the element according to a percentage of the parent dimension. If the parent has no dimensions, then the % will be zero.

Flex layout

It's recommended to use a flex container to render the grid. This allows a flexible layout, resizes well, and works on all devices.

Desk
Commodity
Trader Name
Trader Email
Quantity
D-702
Rough Rice
Isabella White
11,654
D-4226
Oats
Jordan Brewer
19,139
D-5447
Cotton No.2
Lillie Strickland
42,811
D-6947
Soybeans
Nathaniel Peters
78,002
D-7133
Sugar No.14
Estelle Matthews
36,433

Filas por página:

100

1-5 de 5

<div style={{ display: 'flex', height: '100%' }}>
  <div style={{ flexGrow: 1 }}>
    <DataGrid {...data} />
  </div>
</div>

Predefined dimensions

You can predefine dimensions for the parent of the grid.

No rows
Desk
Commodity
Trader Name
Trader Email
Quantity

Filas por página:

100

0-0 de 0

<div style={{ height: 350, width: '100%' }}>
  <DataGrid {...data} />
</div>

Auto height

The autoHeight prop allows the grid to size according to its content. This means that the number of rows will drive the height of the grid and consequently, they will all be rendered and visible to the user at the same time.

⚠️ This is not recommended for large datasets as row virtualization will not be able to improve performance by limiting the number of elements rendered in the DOM.

No rows
Desk
Commodity
Trader Name
Trader Email
Quantity

Filas por página:

100

0-0 de 0

more content

<DataGrid autoHeight {...data} />
<p>more content</p>