AllenFang / AllenFang/react-bootstrap-table

onClick call from within function

Ouverte
#2,018 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
JavaScript
Étoiles
2.2k
Forks
761
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

I have the following code:

```
class ModelsSearch extends CustomTable {

constructor(props) {
super(props);
this.handleDelete = this.handleDelete.bind(this);

this.columns = [
{ width: "5%", path: "id", title: "ID", sort: true, isKey: true},
{ width: "10%", path: "name", title: "Name"},
{ width: "20%", path: "description", title: "Description"},
{ width: "10%", path: "", title: "Actions" , dataFormat: this.modelActions }
];
}

handleDelete() {
console.log("On Click Worked");
}

modelActions(cell, row, extra, index){
return (





{_.get(row, "used") === true ?



:



}

);
}

render() {
return (



{this.renderTableColumns()}


);
}
}
```

I am having considerable difficulty with the onClick call for handleDelete. When I try with the above code I get ```Uncaught TypeError: this.handleDelete is not a function```. I've tried a number of different approaches such as the following changes:

```onClick={() => this.handleDelete()}```
```revenueModelActions = (cell, row, extra, index) => {```

but as yet have been unable to get it working. Any advice is appreciated.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.