-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select/ deselect all rows ignores groups which are collapsed #2273
Comments
|
@nstepien Thanks for the update. |
https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html If you're using webpack, you might need to alias
Upstream bug: facebook/react#20235 |
Thanks a lot for the quick response ! So updating to react@16.14.0 did help me resolve the "react/jsx-runtime" issue. I have updated my application to use the latest canary version i.e. 7.0.0-canary.34 and after that I am getting some errors involving rowKeyGetter prop when I am trying to select a row/all rows from the grid that I am trying to resolve as of now. I will add an update if this fixed my issue. |
The function rowKeyGetter(row) {
return row.id;
}
// ...
<DataGrid rowKeyGetter={rowKeyGetter} /> |
@preetilht can you create a codesandbox example so we can investigate. Grouping example works as expected |
Yeah , I will do that ! |
I am struggling to update my existing code after canary update(34) as I was not able to find documentation on https://adazzle.github.io/react-data-grid/canary (the earlier site for V5 had sandbox examples which made development around the framework easier). Is there any page where I can get a rough idea of the new props/func ? |
Sorry we don't have proper docs yet. We have an example here: |
Thanks for the update ! I just wanted to add in an important point about our scenario because the sandbox might take some time now. We are having some documents (set as the “rows” prop in the grid ) and some of the docs have their child documents as well (they can’t be grouped as there is no common field really between them). So instead of using the grouping props from react-data-grid , we have used a custom expand collapse functionality(on clicking the expand button on a row, the child docs associated with the expanded parent are added to “rows” prop in grid and hence become visible in the grid / no expand button is there for the ones with no child docs ). So, to achieve the selection functionality, we are maintaining states in selectedRows N and selectedDocuments M(M is equal to all docs i.e. parents + child docs) and then in setSelected function, we are manipulating the selectedRows prop to be equal to selectedDocuments. But the problem here is on line 208 ( file lib/Datagrid.js in grid’s codebase ) , so allSelectedRows is getting false because rows < selectedRows in our case which kind of is breaking the workaround as well. So just wanted to make sure if you guys see any other workaround which might work in our case because the grid takes in two props only right now ie selectedRows and rows. |
Sounds like you might want to implement row selection yourself, using a custom column, and maybe have the state stored in your parent component + React context. That way you can have your own custom logic. |
Thanks ! I did what you mentioned above and most of the row selection edge cases work , except for one specific scenario. `const customColumns = { renderSelectCell = (r) => { So in above case , when we "select all" and then expand a row which has some disabled rows in it , the "select all" checkbox also gets unselected (it works fine when everthing is collapsed). To my best guess, this is happening because on expanding a row, normal and disabled rows both get added to grid's rows prop (so it has an extra disabled rows which "selectedRows" prop doesn't have at the time of "select all") which leads to required condition for select all to be false (selectedRows and rows need to be equal) |
I think you want to change the |
Closing due to lack of activity. Please open a new issue if you are still facing problems |
IMPORTANT INFO :
REACT VERSION : 16.13.1
REACT-DATA-GRID VERSION : 7.0.0-canary.16
BROWSER : CHROME Version 87.0.4280.141 (Official Build) (64-bit)
TYPE OF REQUEST : BUG REPORT
DESCRIPTION :
The issue I am facing occurs when grouping and row selection exists together and the rowSelection prop's selectBy is assigned with keys instead of indexes.
Current behaviour is that the when the grid is grouped and the user checks the select all button, all rows gets checked except for the ones that are collapsed. and this happens when deselecting all as well.
In my opinion, this behaviour should work fine and regardless of collapsed/ expanded rpw state, all rows should be selected or deselected.
STEPS TO REPRODUCE
Setup grid with grouping and row selection (selectBy should be initialized with keys).
Collapse one or many groups
Click check all checkbox on the top of the grid
Every row will be checked except for the ones which were collapsed,
SAMPLE CODE
`import ReactDataGrid, { SelectColumn, , Row as GridRow } from 'react-data-grid';
import { DragDropContext } from 'react-beautiful-dnd';
import { ContextMenu } from 'react-contextmenu';
class DocListTable extends React.Component {
constructor(props) {
super(props);
this.state = {
allDocuments: props.documents,
displayedDocuments, //set based on expand/collapse
columns: this.defaultColumns,
expandedRows: [],
selectedRows: new Set(),
selectedDocuments: [],
sortColumn: 'name',
sortDirection: 'ASC',
filters: [],
gridWidth: 750,
};
}
render() {
return (
<ReactDataGrid
rowKey="id"
ref={node => this.grid = node}
columns={this.state.columns}
rows={this.state.displayedDocuments}
enableFilters={this.props.displayFilters}
minColumnWidth="235"
selectedRows={this.state.selectedRows}
onSelectedRowsChange={this.setSelectedRows}
sortColumn={this.state.sortColumn}
sortDirection={this.state.sortDirection}
onSort={this.handleSort}
emptyRowsView={this.emptyRowsView}
onColumnResize={this.resizeColumn}
rowRenderer={this.rowRenderer}
/>
}
}
export default DocListTable;`
The row count/selection functionality is an integral part of our application, so if the team can fix this or provide an update that might prove helpful in handling this , it will be really helpful.
Thanks in advance!
p.s. Please tag if any additional info is required.
The text was updated successfully, but these errors were encountered: