Skip to content
/ mui-x Public
  • Sponsor mui/mui-x

  • Notifications You must be signed in to change notification settings
  • Fork 1.4k

Commit a202034

Browse files
oliviertassinariflaviendelangle
andauthoredNov 7, 2024··
[docs] Add () for updateRows method (#15251)
Signed-off-by: Olivier Tassinari <olivier.tassinari@gmail.com> Co-authored-by: Flavien DELANGLE <flaviendelangle@gmail.com>
1 parent a62b88f commit a202034

File tree

8 files changed

+33
-34
lines changed

8 files changed

+33
-34
lines changed
 

‎CHANGELOG.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,9 @@ No changes since `@mui/x-tree-view@7.12.0`.
861861

862862
### Docs
863863

864-
- [docs] Add a warning to promote the usage of `updateRows` (#14027) @MBilalShafi
864+
- [docs] Add a warning to promote the usage of `updateRows()` (#14027) @MBilalShafi
865865
- [docs] Disable ad in `Rich Tree View-Ordering` page (#14123) @oliviertassinari
866866
- [docs] Redesign Date and Time Pickers overview page (#13241) @noraleonte
867-
868867
- [CHANGELOG] Polish details @oliviertassinari
869868
- [code-infra] Use concurrency 1 in CircleCI (#14110) @JCQuintas
870869
- [infra] Re-added the removal of `Latest Version` section (#14132) @michelengelen

‎changelogOld/CHANGELOG.v4.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -378,23 +378,23 @@ Big thanks to the 11 contributors who made this release possible. Here are some
378378

379379
- [DataGrid] Improve the editing API (#1955) @m4theushw
380380

381-
- The `props` key in the first argument of `commitCellChange` was removed to promote the use of the value already stored in the state.
382-
To update the value in the state, call `setEditCellProps` before.
381+
- The `props` key in the first argument of `commitCellChange()` was removed to promote the use of the value already stored in the state.
382+
To update the value in the state, call `setEditCellProps()` before.
383383

384384
```diff
385385
-apiRef.current.commitCellChange({ id: 1, field: 'name', props: { value: 'Ana' } });
386386
+apiRef.current.setEditCellProps({ id: 1, field: 'name', props: { value: 'Ana' } });
387387
+apiRef.current.commitCellChange({ id: 1, field: 'name' });
388388
```
389389

390-
- Calling `commitCellChange` in a cell in view mode will throw an error. Make sure to first enter the edit mode.
390+
- Calling `commitCellChange()` in a cell in view mode throws an error. Make sure to first enter the edit mode.
391391

392392
```diff
393393
+apiRef.current.setCellMode(1, 'name', 'edit');
394394
apiRef.current.commitCellChange({ id: 1, field: 'name' });
395395
```
396396

397-
- The `setCellValue` was removed from the API. Use `commitCellChange` or `updateRows` in place.
397+
- The `setCellValue()` was removed from the API. Use `commitCellChange()` or `updateRows()` in place.
398398

399399
```diff
400400
-apiRef.current.setCellValue({ id: 1, field: 'name', value: 'Ana' });
@@ -1807,7 +1807,7 @@ Big thanks to the 8 contributors who made this release possible. Here are some h
18071807
+apiRef.current.setRows()
18081808
```
18091809

1810-
`apiRef.current.updateRowModels` has been removed, please use `apiRef.current.updateRows`.
1810+
`apiRef.current.updateRowModels()` has been removed, please use `apiRef.current.updateRows()`.
18111811

18121812
#### Changes
18131813

‎changelogOld/CHANGELOG.v5.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ We'd like to offer a big thanks to the 5 contributors who made this release poss
3434
#### Changes
3535

3636
- [DataGrid] Allow to pass props to the `FocusTrap` inside the panel wrapper (#7897) @Vivek-Prajapatii
37-
- [DataGrid] Avoid unnecessary rerenders after `updateRows` (#7945) @cherniavskii
37+
- [DataGrid] Avoid unnecessary rerenders after `updateRows()` (#7945) @cherniavskii
3838
- [DataGridPro] Change cursor when dragging a column (#7878) @sai6855
3939
- [DataGridPremium] Fix `leafField` to have correct focus value (#7959) @MBilalShafi
4040

@@ -332,7 +332,7 @@ We'd like to offer a big thanks to the 7 contributors who made this release poss
332332

333333
- [DataGrid] Fix `ErrorOverlay` not receiving defined input props (#6885) @banoth-ravinder
334334
- [DataGrid] Improve typing for `styleOverrides` (#6980) @iigrik
335-
- [DataGridPro] Fix lazy-loaded rows not working with `updateRows` API method (#6875) @cherniavskii
335+
- [DataGridPro] Fix lazy-loaded rows not working with `updateRows()` API method (#6875) @cherniavskii
336336
- [l10n] Fix translation of `filterOperatorBefore` in Arabic (ar-SD) locale (#6917) @HassanGhazy
337337

338338
### `@mui/x-date-pickers@v5.0.9` / `@mui/x-date-pickers-pro@v5.0.9`
@@ -2184,7 +2184,7 @@ A big thanks to the 9 contributors who made this release possible. Here are some
21842184
- [DataGrid] Fix `isRowSelectable` when `paginationMode='server'` (#3647) @flaviendelangle
21852185
- [DataGrid] Fix browser keyboard shortcuts not working when header cell is focused (#3692) @valenfv
21862186
- [DataGrid] Fix focus on checkbox cells (#3501) @alexfauquette
2187-
- [DataGrid] Only update the visibility status of the updated columns when calling `apiRef.current.updateRows` (#3735) @flaviendelangle
2187+
- [DataGrid] Only update the visibility status of the updated columns when calling `updateRows()` (#3735) @flaviendelangle
21882188
- [DataGrid] Prevent commit if `preProcessEditCellProps` resolves with an error (#3612) @m4theushw
21892189
- [DataGrid] Update selected rows when turning off `checkboxSelection` (#3684) @m4theushw
21902190
- [DataGrid] Variable row height (#3218) @DanailH
@@ -2726,10 +2726,10 @@ A big thanks to the 7 contributors who made this release possible. Here are some
27262726

27272727
#### Changes
27282728

2729-
- [DataGrid] Block multi-rows updates in `apiRef.current.updateRows` on the Community plan (#3095) @flaviendelangle
2729+
- [DataGrid] Block multi-rows updates in `updateRows()` on the Community plan (#3095) @flaviendelangle
27302730
- [DataGrid] Fix filter not working after deleting the value (#3018) @m4theushw
27312731
- [DataGrid] Fix performance regression when selecting 100k rows (#3077) @m4theushw
2732-
- [DataGrid] Fix `apiRef.current.updateRows` to not share rows from other instances (#3127) @m4theushw
2732+
- [DataGrid] Fix `updateRows()` to not share rows from other instances (#3127) @m4theushw
27332733
- [DataGrid] Fix flex space allocation to not cause a horizontal scroll when there is enough space (#3099) @flaviendelangle
27342734
- [DataGrid] Improve the filter panel behaviors (#3080) @flaviendelangle
27352735
- [DataGrid] Fix keyboard navigation between column headers and rows when not on the first page (#3086) @flaviendelangle

‎changelogOld/CHANGELOG.v6.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2625,7 +2625,7 @@ We'd like to offer a big thanks to the 7 contributors who made this release poss
26252625
- [DataGrid] Fix missing watermark in Pro and Premium packages (#8797) @cherniavskii
26262626
- [DataGrid] Remove unwarranted warning log (#8847) @romgrk
26272627
- [DataGrid] Add Joy UI slots (`Select`, `SelectOption`, `InputLabel`, `FormControl`) (#8747) @cherniavskii
2628-
- [DataGridPremium] Fix expanded groups being collapsed after calling `updateRows` (#8823) @cherniavskii
2628+
- [DataGridPremium] Fix expanded groups being collapsed after calling `updateRows()` (#8823) @cherniavskii
26292629

26302630
### `@mui/x-date-pickers@6.3.1` / `@mui/x-date-pickers-pro@6.3.1`
26312631

@@ -3256,7 +3256,7 @@ We'd like to offer a big thanks to the 8 contributors who made this release poss
32563256

32573257
- [DataGrid] Add interface for `singleSelect` column (#7685) @m4theushw
32583258
- [DataGrid] Allow to pass props to the `FocusTrap` inside the panel wrapper (#7733) @ivek-Prajapatii
3259-
- [DataGrid] Avoid unnecessary rerenders after `updateRows` (#7857) @cherniavskii
3259+
- [DataGrid] Avoid unnecessary rerenders after `updateRows()` (#7857) @cherniavskii
32603260
- [DataGridPro] Change cursor when dragging a column (#7725) @sai6855
32613261
- [DataGridPremium] Fix `leafField` to have correct focus value (#7950) @MBilalShafi
32623262

@@ -4362,7 +4362,7 @@ We'd like to offer a big thanks to the 14 contributors who made this release pos
43624362
- [DataGrid] Stop exporting root base state selectors (#6912) @DanailH
43634363
- [DataGrid] Support `theme.vars` (#6784) @alexfauquette
43644364
- [DataGrid] Rename `rowsScroll` event to `scrollPositionChange` (#6957) @DanailH
4365-
- [DataGridPro] Fix lazy-loaded rows not working with `updateRows` API method (#6976) @cherniavskii
4365+
- [DataGridPro] Fix lazy-loaded rows not working with `updateRows()` API method (#6976) @cherniavskii
43664366
- [DataGridPremium] Improve typing for theme in `styleOverrides` (#6920) @m4theushw
43674367
- [l10n] Fix translation of `filterOperatorBefore` in Arabic (ar-SD) locale (#6884) @HassanGhazy
43684368

‎docs/data/data-grid/editing/editing.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ The callback is called with three arguments:
162162
3. An object with additional properties such as `rowId`.
163163

164164
Please note that the `processRowUpdate` must return the row object to update the Data Grid internal state.
165-
The value returned is used later as an argument on a call to `apiRef.current.updateRows`.
165+
The value returned is used later as an argument on a call to `apiRef.current.updateRows()`.
166166

167167
```tsx
168168
<DataGrid
@@ -176,7 +176,7 @@ The value returned is used later as an argument on a call to `apiRef.current.upd
176176
```
177177

178178
If you want to delete a row from the internal state of the Data Grid, you can return an additional property `_action: 'delete'` in the row object from the `processRowUpdate` callback. This will remove the row from the internal state of the Data Grid.
179-
It is a more performant way to delete a row as compared to updating the [`rows` prop](/x/react-data-grid/row-updates/#the-rows-prop) or using `setRows` API method because `processRowUpdate` uses the [`updateRows`](https://mui.com/x/react-data-grid/row-updates/#the-updaterows-method) under the hood which doesn't cause a full regeneration of the row tree.
179+
It is a more performant way to delete a row as compared to updating the [`rows` prop](/x/react-data-grid/row-updates/#the-rows-prop) or using `setRows()` API method because `processRowUpdate` uses the [`updateRows()`](https://mui.com/x/react-data-grid/row-updates/#the-updaterows-method) under the hood which doesn't cause a full regeneration of the row tree.
180180

181181
```tsx
182182
<DataGrid
@@ -378,7 +378,7 @@ These are the most important params to consider:
378378
- `isProcessingProps`: whether `preProcessEditCellProps` is being executed or not
379379

380380
Once a new value is entered into the input, it must be sent to the Data Grid.
381-
To do this, pass the row ID, the column field, and the new cell value to a call to `apiRef.current.setEditCellValue`.
381+
To do this, pass the row ID, the column field, and the new cell value to a call to `apiRef.current.setEditCellValue()`.
382382
The new value will be parsed and validated, and the `value` prop will reflect the changes in the next render.
383383

384384
It's important to also handle the [accessibility](/x/react-data-grid/accessibility/) of custom edit components.
@@ -413,17 +413,17 @@ The following demo implements a custom edit component, based on the [`Rating`](h
413413

414414
### With debounce
415415

416-
By default, each call to `apiRef.current.setEditCellValue` triggers a new render.
416+
By default, each call to `apiRef.current.setEditCellValue()` triggers a new render.
417417
If the edit component requires the user to type a new value, re-rendering the Data Grid too often will drastically reduce performance.
418418
One way to avoid this is to debounce the API calls.
419-
You can use `apiRef.current.setEditCellValue` to handle debouncing by setting the `debounceMs` param to a positive integer that defines a set time period in milliseconds.
419+
You can use `apiRef.current.setEditCellValue()` to handle debouncing by setting the `debounceMs` param to a positive integer that defines a set time period in milliseconds.
420420
No matter how many times the API method is called, the Data Grid will only be re-rendered after that period of time has passed.
421421

422422
```tsx
423423
apiRef.current.setEditCellValue({ id, field, value: newValue, debounceMs: 200 });
424424
```
425425

426-
When the Data Grid is only set to re-render after a given period of time has passed, the `value` prop will not be updated on each `apiRef.current.setEditCellValue` call.
426+
When the Data Grid is only set to re-render after a given period of time has passed, the `value` prop will not be updated on each `apiRef.current.setEditCellValue()` call.
427427
To avoid a frozen UI, the edit component can keep the current value in an internal state and sync it once `value` changes.
428428
Modify the edit component to enable this feature:
429429

@@ -456,8 +456,8 @@ To picture better, imagine an edit component with a combo, created following the
456456
By default, it would require two clicks to change the value of the cell: one click inside the cell to select a new value, and another click outside the cell to save.
457457
This second click can be avoided if the first click also stops the edit mode.
458458
To create an edit component with auto-stop, call `apiRef.current.stopCellEditMode` after setting the new value.
459-
Since `apiRef.current.setEditCellValue` may do additional processing, you must wait for it to resolve before stopping the edit mode.
460-
Also, it is a good practice to check if `apiRef.current.setEditCellValue` has returned `true`.
459+
Since `apiRef.current.setEditCellValue()` may do additional processing, you must wait for it to resolve before stopping the edit mode.
460+
Also, it is a good practice to check if `apiRef.current.setEditCellValue()` has returned `true`.
461461
It will be `false` if `preProcessEditProps` set an error during [validation](#validation).
462462

463463
```tsx
@@ -479,7 +479,7 @@ The following demo implements an edit component with auto-stop, based on a nativ
479479
{{"demo": "AutoStopEditComponent.js", "bg": "inline", "defaultCodeOpen": false}}
480480

481481
:::warning
482-
Avoid using edit components with auto-stop in columns that use long-running `preProcessEditCellProps` because the UI will freeze while waiting for `apiRef.current.setEditCellValue`.
482+
Avoid using edit components with auto-stop in columns that use long-running `preProcessEditCellProps` because the UI will freeze while waiting for `apiRef.current.setEditCellValue()`.
483483
Instead, use the provided interactions to exit edit mode.
484484
:::
485485

‎docs/data/data-grid/recipes-editing/recipes-editing.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The code above is already enough to display different options in the **Account**
5252
The only task left is to reset the account once the type is changed.
5353
This is needed because the previously selected account will not exist now in the options.
5454
To solve that, you can create a custom edit component, reusing the built-in one, and pass a function to the `onValueChange` prop.
55-
This function should call `apiRef.current.setEditCellValue` to reset the value of the other field.
55+
This function should call `apiRef.current.setEditCellValue()` to reset the value of the other field.
5656

5757
```tsx
5858
const CustomTypeEditComponent = (props: GridEditSingleSelectCellProps) => {
@@ -77,7 +77,7 @@ The **Account** column is automatically updated with the correct options.
7777
{{"demo": "LinkedFieldsRowEditing.js", "bg": "inline", "defaultCodeOpen": false}}
7878

7979
:::warning
80-
The call to `apiRef.current.setEditCellValue` returns a promise that must be awaited.
80+
The call to `apiRef.current.setEditCellValue()` returns a promise that must be awaited.
8181
For instance, if the `singleSelect` column type is used, not awaiting will cause the other column to be rendered with a `value` that is not in the options.
8282

8383
```ts
@@ -93,7 +93,7 @@ const handleChange = async () => {
9393
:::
9494

9595
A similar behavior can be reproduced with cell editing.
96-
Instead of `apiRef.current.setEditCellValue`, the `rows` prop must be updated or `apiRef.current.updateRows` be used.
96+
Instead of `apiRef.current.setEditCellValue()`, the `rows` prop must be updated or `apiRef.current.updateRows()` be used.
9797
Note that the `onCellEditStart` and `onCellEditStop` props also have to be used to revert the value of the cell changed, in case the user cancels the edit.
9898

9999
{{"demo": "LinkedFieldsCellEditing.js", "bg": "inline", "defaultCodeOpen": false}}

‎docs/data/data-grid/row-updates/row-updates.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ It replaces the previous values. This approach has some drawbacks:
1414

1515
:::warning
1616
Updating the `rows` prop causes the Data Grid to recompute the row tree, resulting in losing the current tree information like the expanded rows state.
17-
Unless the recomputation is explicitly required, the API method `updateRows` should be used.
17+
Unless the recomputation is explicitly required, the API method `updateRows()` should be used.
1818
:::
1919

20-
## The `updateRows` method
20+
## The `updateRows()` method
2121

22-
If you want to only update part of the rows, you can use the `apiRef.current.updateRows` method.
22+
If you want to only update part of the rows, you can use the `apiRef.current.updateRows()` method.
2323

2424
{{"demo": "UpdateRowsApiRef.js", "bg": "inline"}}
2525

26-
The default behavior of `updateRows` API is to upsert rows.
26+
The default behavior of `updateRows()` API is to upsert rows.
2727
So if a row has an id that is not in the current list of rows then it will be added to the Data Grid.
2828

2929
Alternatively, if you would like to delete a row, you would need to pass an extra `_action` property in the update object as below.
@@ -33,7 +33,7 @@ apiRef.current.updateRows([{ id: 1, _action: 'delete' }]);
3333
```
3434

3535
:::info
36-
The community version of the Data Grid is limited to a single row update per `apiRef.current.updateRows` call.
36+
The community version of the Data Grid is limited to a single row update per `apiRef.current.updateRows()` call.
3737
Multiple row updates at a time are supported in [Pro](/x/introduction/licensing/#pro-plan) and [Premium](/x/introduction/licensing/#premium-plan) plans.
3838
:::
3939

‎docs/data/migration/migration-data-grid-v5/migration-data-grid-v5.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ Most of this breaking change is handled by `preset-safe` codemod but some furthe
297297
+ const focusedField = props.focusedCell;
298298
+ const tabIndex = props.tabbableCell === column.field ? 0 : 1;
299299
```
300-
- Updating the [`rows` prop](/x/react-data-grid/row-updates/#the-rows-prop) or calling `apiRef.current.setRows` will now remove the expansion state of the grid as these methods are meant to replace the rows.
301-
For partial row updates, use the [`apiRef.current.updateRows`](/x/react-data-grid/row-updates/#the-updaterows-method) method instead.
300+
- Updating the [`rows` prop](/x/react-data-grid/row-updates/#the-rows-prop) or calling `apiRef.current.setRows()` will now remove the expansion state of the grid as these methods are meant to replace the rows.
301+
For partial row updates, use the [`apiRef.current.updateRows()`](/x/react-data-grid/row-updates/#the-updaterows-method) method instead.
302302

303303
### Pagination
304304

0 commit comments

Comments
 (0)
Please sign in to comment.