gregnb / gregnb/mui-datatables

isRowSelectable does not work with selectableRowsHeader

Open
#1,571 1 comment 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.7k
Forks
906
PR merge metrics
No merged PRs in 30d

Description

If you use `isRowSelectable` to limit the number of selectable rows:

```
isRowSelectable: (dataIndex, selectedRows) => {
if (selectedRows.data.length >= selectRowMax &&
selectedRows.data.filter((d) => d.dataIndex === dataIndex).length ===
0) return false;
return true;
```
and you also have `selectableRowsHeader: true`

Any use of the select all header checkbox will surpass the limits set by `isRowSelectable`. Looking at [selectRowUpdate](https://github.com/gregnb/mui-datatables/blob/a879dc482b2450faf7f50220c050e0211bb66e2d/src/MUIDataTable.js#L1597) is there any way for a consumer of this table to override `selectRowUpdate` to support custom behavior like this without completely forking this repo?

Any advice on how to accomplish this would be greatly appreciated!

Thank you

## Expected Behavior
- `isRowSelectable` is honored by the header select-all checkbox
OR
- Using a new config option `selectAllMaximum`, `selectRowUpdate` honor this option for select all.

## Current Behavior
- `isRowSelectable` is bypassed by the header select-all checkbox

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/MUIDataTable.js at the linked selectRowUpdate implementation and trace how the selectableRowsHeader checkbox selects rows. Verify the behavior against the isRowSelectable example and make the header selection honor the stated selection limit or an explicitly chosen configuration behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.