AllenFang / AllenFang/react-bootstrap-table

onClick call from within function

Đang mở
#2,018 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
2.2k
Fork
761
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.