Skip to content

Commit 21a5426

Browse files
authored
Merge pull request #8677 from marmelab/fix-datagrid-rowclick-type
Fix `<Datagrid>` `rowClick` type and documentation
2 parents 737f6f0 + 4fec046 commit 21a5426

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

docs/Datagrid.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,10 @@ export const PostList = () => (
655655
* "show" to redirect to the show vue
656656
* "expand" to open the `expand` panel
657657
* "toggleSelection" to trigger the `onToggleItem` function
658-
* a function `(id, resource, record) => path` to redirect to a custom path
658+
* `false` to do nothing
659+
* a function `(id, resource, record) => path` that may return any of the above values or a custom path
659660

660-
**Tip**: If you pass a function, it can return `edit`, `show`; or a router path. This allows to redirect to either `edit` or `show` after checking a condition on the record. For example:
661+
**Tip**: If you pass a function, it can return `'edit'`, `'show'`, `false` or a router path. This allows to redirect to either the Edit or Show view after checking a condition on the record. For example:
661662

662663
```js
663664
const postRowClick = (id, resource, record) => record.editable ? 'edit' : 'show';

packages/ra-ui-materialui/src/list/datagrid/Datagrid.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ export interface DatagridProps<RecordType extends RaRecord = any>
337337
isRowSelectable?: (record: RecordType) => boolean;
338338
isRowExpandable?: (record: RecordType) => boolean;
339339
optimized?: boolean;
340-
rowClick?: string | RowClickFunction;
340+
rowClick?: string | RowClickFunction | false;
341341
rowStyle?: (record: RecordType, index: number) => any;
342342
size?: 'medium' | 'small';
343343
// can be injected when using the component without context

packages/ra-ui-materialui/src/list/datagrid/DatagridBody.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export interface DatagridBodyProps extends Omit<TableBodyProps, 'classes'> {
105105
record?: RaRecord;
106106
resource?: string;
107107
row?: ReactElement;
108-
rowClick?: string | RowClickFunction;
108+
rowClick?: string | RowClickFunction | false;
109109
rowStyle?: (record: RaRecord, index: number) => any;
110110
selectedIds?: Identifier[];
111111
isRowSelectable?: (record: RaRecord) => boolean;

0 commit comments

Comments
 (0)