bencripps / react-redux-grid

A React Grid/Tree Component written in the Redux Pattern
http://react-redux-grid.herokuapp.com/
MIT License
444 stars 63 forks source link

bulk selection needs to add all row indexes to the selection store #145

Closed headwinds closed 7 years ago

headwinds commented 7 years ago

If you click the bulk check box, all the rows are visually selected but the indexes array is not available like it is when you check the rows individually.

const indexes = this.props.selection.get("myGrid").get("indexes");

indexes should be defined as an array with all the row indexes after clicking the bulk checkbox.

For instance, in a grid with 10 rows. If you begin with a bulk check then manually uncheck a row, you should now have 9 indexes but indexes is undefined. If you check that same row again, indexes is now defined but with 1 not 10.

@bencripps I'm going to try to fix this and update the tests. I just wanted to capture it. Please assign it to me.

headwinds commented 7 years ago

the workaround is not use to indexes - instead the selected state of each row which is actually included within selection although its not reflected in indexes.

const selection = this.props.selection.get("workbench");
const selectionData = selection.toJS(); 
const selectedIds = [];
for (var key in selectionData) {
  if (selectionData[key]) {
    let selectedId = key.split("row-")[1];
    if ("NaN" !== String(Number(selectedId))) selectedIds.push(Number(selectedId));
  }
}

selectionData looks like:

{
indexes: Array[0],
lastUpdate: 6,
row-0: true,
row-1: false,
row-2: true,
row-3: true
}
bencripps commented 7 years ago

This was resolved with #160