Skip to content

DataGrid overriding DataGridBody example in documentation is incorrect #6222

Closed

Description

What you were expecting:
Disabled checkboxes where isRowSelectable criteria is false and the remaining rows remain selectable

What happened instead:

Error when clicking a checkbox due to missing event parameter
Steps to reproduce:

Follow example from here: https://marmelab.com/react-admin/List.html#body-element

I fixed it by making the following changes:
Adding selectable prop instead of record.selectable which doesn't exist
and added event parameter as onToggleItem expects this

const MyDatagridRow = ({ record, resource, id, onToggleItem, children, selected, selectable, basePath }) => (
    <TableRow key={id}>
        {/* first column: selection checkbox */}
        <TableCell padding="none">
            <Checkbox
                disabled={selectable}
                checked={selected}
                onClick={(event) => onToggleItem(id, event)}
            />
        </TableCell>
        {/* data columns based on children */}
        {React.Children.map(children, field => (
            <TableCell key={`${id}-${field.props.source}`}>
                {React.cloneElement(field, {
                    record,
                    basePath,
                    resource,
                })}
            </TableCell>
        ))}
    </TableRow>
);```


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions