1

I need some help by toggle Values from a table row in a Child Component.

It should only be showen if i click on a row. This happens fine. But if i click in the next row it closes the Details, but it should only switch the value. If i click in the same row twice it should close the Details.

Workaround here

3 Answers 3

1

You have to change your toggleDetails function like this

toggleDetails(row) {
    console.log(row);
    if (this.rowData == row) {
      this.showDetails = !this.showDetails;
    } else {
      this.showDetails = true;
    }

    this.rowData = row;
  }

This will work!

0
1

try this :

toggleDetails(row) {
    console.log(row);
    this.showDetails = row.position !== this.rowData.position || !this.showDetails;
    this.rowData = row;
  }
2
  • Works but with small issue. "this.rowData.position" "Property position does not exists on type {}. Nov 20, 2019 at 9:24
  • this.rowData : any = {} will fix this issue Nov 20, 2019 at 9:47
1

Please see the working demo here. I have modified the toggleDetails method.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.