Skip to content

Commit

Permalink
Remove expanded index
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle committed Apr 6, 2022
1 parent edb129b commit ef7c982
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 49 deletions.
19 changes: 9 additions & 10 deletions docs/pages/api-docs/data-grid/grid-row-class-name-params.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ import { GridRowClassNameParams } from '@mui/x-data-grid';

## Properties

| Name | Type | Description |
| :--------------------------------------------------------- | :---------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------- |
| <span class="prop-name">columns</span> | <span class="prop-type">GridColumns</span> | All grid columns. |
| <span class="prop-name">getValue</span> | <span class="prop-type">(id: GridRowId, field: string) =&gt; any</span> | Get the cell value of a row and field. |
| <span class="prop-name">id</span> | <span class="prop-type">GridRowId</span> | The grid row id. |
| <span class="prop-name">indexRelativeToCurrentPage</span> | <span class="prop-type">number</span> | Index of the row in the current page.<br />If the pagination is disabled, this value will be equal to the `indexRelativeToExpandedRows` value. |
| <span class="prop-name">indexRelativeToExpandedRows</span> | <span class="prop-type">number</span> | Index of the row in the whole sorted and filtered dataset.<br />If some rows have children, this value only counts the expanded children. |
| <span class="prop-name">isFirstVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the first visible or not. |
| <span class="prop-name">isLastVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the last visible or not. |
| <span class="prop-name">row</span> | <span class="prop-type">R</span> | The row model of the row that the current cell belongs to. |
| Name | Type | Description |
| :-------------------------------------------------------- | :---------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------- |
| <span class="prop-name">columns</span> | <span class="prop-type">GridColumns</span> | All grid columns. |
| <span class="prop-name">getValue</span> | <span class="prop-type">(id: GridRowId, field: string) =&gt; any</span> | Get the cell value of a row and field. |
| <span class="prop-name">id</span> | <span class="prop-type">GridRowId</span> | The grid row id. |
| <span class="prop-name">indexRelativeToCurrentPage</span> | <span class="prop-type">number</span> | Index of the row in the current page.<br />If the pagination is disabled, it will be the index relative to all filtered rows. |
| <span class="prop-name">isFirstVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the first visible or not. |
| <span class="prop-name">isLastVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the last visible or not. |
| <span class="prop-name">row</span> | <span class="prop-type">R</span> | The row model of the row that the current cell belongs to. |
15 changes: 7 additions & 8 deletions docs/pages/api-docs/data-grid/grid-row-spacing-params.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import { GridRowSpacingParams } from '@mui/x-data-grid';

## Properties

| Name | Type | Description |
| :--------------------------------------------------------- | :--------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------- |
| <span class="prop-name">id</span> | <span class="prop-type">GridRowId</span> | The row id. |
| <span class="prop-name">indexRelativeToCurrentPage</span> | <span class="prop-type">number</span> | Index of the row in the current page.<br />If the pagination is disabled, this value will be equal to the `indexRelativeToExpandedRows` value. |
| <span class="prop-name">indexRelativeToExpandedRows</span> | <span class="prop-type">number</span> | Index of the row in the whole sorted and filtered dataset.<br />If some rows have children, this value only counts the expanded children. |
| <span class="prop-name">isFirstVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the first visible or not. |
| <span class="prop-name">isLastVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the last visible or not. |
| <span class="prop-name">model</span> | <span class="prop-type">R</span> | The row model. |
| Name | Type | Description |
| :-------------------------------------------------------- | :--------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------- |
| <span class="prop-name">id</span> | <span class="prop-type">GridRowId</span> | The row id. |
| <span class="prop-name">indexRelativeToCurrentPage</span> | <span class="prop-type">number</span> | Index of the row in the current page.<br />If the pagination is disabled, it will be the index relative to all filtered rows. |
| <span class="prop-name">isFirstVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the first visible or not. |
| <span class="prop-name">isLastVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the last visible or not. |
| <span class="prop-name">model</span> | <span class="prop-type">R</span> | The row model. |
19 changes: 9 additions & 10 deletions docs/pages/x/api/data-grid/grid-row-class-name-params.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ import { GridRowClassNameParams } from '@mui/x-data-grid';

## Properties

| Name | Type | Description |
| :--------------------------------------------------------- | :---------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------- |
| <span class="prop-name">columns</span> | <span class="prop-type">GridColumns</span> | All grid columns. |
| <span class="prop-name">getValue</span> | <span class="prop-type">(id: GridRowId, field: string) =&gt; any</span> | Get the cell value of a row and field. |
| <span class="prop-name">id</span> | <span class="prop-type">GridRowId</span> | The grid row id. |
| <span class="prop-name">indexRelativeToCurrentPage</span> | <span class="prop-type">number</span> | Index of the row in the current page.<br />If the pagination is disabled, this value will be equal to the `indexRelativeToExpandedRows` value. |
| <span class="prop-name">indexRelativeToExpandedRows</span> | <span class="prop-type">number</span> | Index of the row in the whole sorted and filtered dataset.<br />If some rows have children, this value only counts the expanded children. |
| <span class="prop-name">isFirstVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the first visible or not. |
| <span class="prop-name">isLastVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the last visible or not. |
| <span class="prop-name">row</span> | <span class="prop-type">R</span> | The row model of the row that the current cell belongs to. |
| Name | Type | Description |
| :-------------------------------------------------------- | :---------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------- |
| <span class="prop-name">columns</span> | <span class="prop-type">GridColumns</span> | All grid columns. |
| <span class="prop-name">getValue</span> | <span class="prop-type">(id: GridRowId, field: string) =&gt; any</span> | Get the cell value of a row and field. |
| <span class="prop-name">id</span> | <span class="prop-type">GridRowId</span> | The grid row id. |
| <span class="prop-name">indexRelativeToCurrentPage</span> | <span class="prop-type">number</span> | Index of the row in the current page.<br />If the pagination is disabled, it will be the index relative to all filtered rows. |
| <span class="prop-name">isFirstVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the first visible or not. |
| <span class="prop-name">isLastVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the last visible or not. |
| <span class="prop-name">row</span> | <span class="prop-type">R</span> | The row model of the row that the current cell belongs to. |
15 changes: 7 additions & 8 deletions docs/pages/x/api/data-grid/grid-row-spacing-params.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import { GridRowSpacingParams } from '@mui/x-data-grid';

## Properties

| Name | Type | Description |
| :--------------------------------------------------------- | :--------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------- |
| <span class="prop-name">id</span> | <span class="prop-type">GridRowId</span> | The row id. |
| <span class="prop-name">indexRelativeToCurrentPage</span> | <span class="prop-type">number</span> | Index of the row in the current page.<br />If the pagination is disabled, this value will be equal to the `indexRelativeToExpandedRows` value. |
| <span class="prop-name">indexRelativeToExpandedRows</span> | <span class="prop-type">number</span> | Index of the row in the whole sorted and filtered dataset.<br />If some rows have children, this value only counts the expanded children. |
| <span class="prop-name">isFirstVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the first visible or not. |
| <span class="prop-name">isLastVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the last visible or not. |
| <span class="prop-name">model</span> | <span class="prop-type">R</span> | The row model. |
| Name | Type | Description |
| :-------------------------------------------------------- | :--------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------- |
| <span class="prop-name">id</span> | <span class="prop-type">GridRowId</span> | The row id. |
| <span class="prop-name">indexRelativeToCurrentPage</span> | <span class="prop-type">number</span> | Index of the row in the current page.<br />If the pagination is disabled, it will be the index relative to all filtered rows. |
| <span class="prop-name">isFirstVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the first visible or not. |
| <span class="prop-name">isLastVisible</span> | <span class="prop-type">boolean</span> | Whether this row is the last visible or not. |
| <span class="prop-name">model</span> | <span class="prop-type">R</span> | The row model. |
1 change: 0 additions & 1 deletion packages/grid/x-data-grid/src/components/GridRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ function GridRow(props: React.HTMLAttributes<HTMLDivElement> & GridRowProps) {
...apiRef.current.getRowParams(rowId),
isFirstVisible: indexRelativeToCurrentPage === 0,
isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
indexRelativeToExpandedRows: index,
indexRelativeToCurrentPage,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ export const useGridRowsMeta = (
...row,
isFirstVisible: indexRelativeToCurrentPage === 0,
isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
indexRelativeToExpandedRows:
indexRelativeToCurrentPage + currentPage.range?.firstRowIndex!,
indexRelativeToCurrentPage,
});

Expand Down
7 changes: 1 addition & 6 deletions packages/grid/x-data-grid/src/models/params/gridRowParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,9 @@ interface GridRowVisibilityParams {
* Whether this row is the last visible or not.
*/
isLastVisible: boolean;
/**
* Index of the row in the whole sorted and filtered dataset.
* If some rows have children, this value only counts the expanded children.
*/
indexRelativeToExpandedRows: number;
/**
* Index of the row in the current page.
* If the pagination is disabled, this value will be equal to the `indexRelativeToExpandedRows` value.
* If the pagination is disabled, it will be the index relative to all filtered rows.
*/
indexRelativeToCurrentPage: number;
}
Expand Down
Loading

0 comments on commit ef7c982

Please sign in to comment.