AllenFang / AllenFang/react-bootstrap-table

onClick call from within function

Offen
#2,018 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
2.2k
Forks
761
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.