AllenFang / AllenFang/react-bootstrap-table

onClick call from within function

未關閉
#2,018 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
2.2k
分支
761
PR 合併指標
30 天內沒有已合併 PR

描述

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.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。