Linked Questions

Popular Questions

How to get checkbox index / row number?

Asked by At

I have checkboxes on a table that, when checked, I would like to append values to an array from the data populating the table ( in my code below).

I already have a toggleRow method that is called when a checkbox is clicked, but how can I append the matching to an array when a checkbox is clicked? I.e. how do I get the index of the checkbox's row that was clicked so that I can grab the right value from my tableData array?

  componentDidMount() {
    const _self = this;

    .then((response) => response.json())
    .then((data) => {

      const tableContent = [];

      data.array.forEach(element => {
          title: element.title,
          link: <Link to='' onClick={(e)=> {e.preventDefault(); this.getPreauthorizedLink(}}>Report</Link>


      this.tableData = tableContent;

      this.setState({reportJSON: tableContent || [], tableIsBusy: false})

    .catch((err) => _self.setState({tableIsBusy: false }));

  toggleRow(name, id) {
    const newSelected = Object.assign({}, this.state.selected);

    let awsFileKeys = [];

      delete newSelected[name]
    }else {
          newSelected[name] = !this.state.selected[name];
            selected: newSelected,
            selectAll: 2


Related Questions