Material-table: Wrong row getting selected with onSelectionChange.

Created on 30 Apr 2019  路  4Comments  路  Source: mbrn/material-table

Describe the bug
I am using pageSize: 20 for pagination; on going to second page(that is from row 21), if try to select a row, the visual effect of checkbox selection is not happening and if i try to select row 1 from second page (that is row 21 in actual table ) row 1(from actual table ) is getting selected instead of 21(from page 1).

To Reproduce
My code-
onSelectionChange={data => this.selectionChanged(data)}
selectionChanged = data => {
console.log(data);
let jobs = [];
let count = 0;
this.setState({ checked: true });

data.forEach((element, index, array) => {
  count++;
  jobs.push(element._id);
  if (count === array.length) {
    this.setState({ JobId: jobs }, () => console.log(this.state.JobId));
    console.log(jobs, "ids");
    console.log(array.length);
  }
});

};

Expected behavior
I expected correct rows to be selected.

Desktop (please complete the following information):

  • OS: [Linux]
  • Browser [chrome]

Additional context
Is this related to calling setState in OnSelectionchange? If yes, what could be the possible alternatives?

bug

All 4 comments

Hi @uplsaurabhA ,

Which version do you use? I tested it in latest version and it seems working properly.

1.17.0

Latest version is 1.34.1 now :). I fixed it on previous version.

Thanks, issue resolved after updating.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

victorwvieira picture victorwvieira  路  3Comments

jlgreene2 picture jlgreene2  路  3Comments

balibou picture balibou  路  3Comments

KKrisu picture KKrisu  路  3Comments

slevy85 picture slevy85  路  3Comments