【发布时间】:2021-07-10 21:17:31
【问题描述】:
如何知道在 onRowSelect 方法中该行是否被选中?
import MUIDataTable from "mui-datatables";
...
const [ total, setTotal ] = useState(0);
...
const handleRowSelect = (curRowSelected) => {
console.log(curRowSelected);
const val = credits[curRowSelected[0].index].amount;
// I want to add a condition: IF selected, I'll add value to my total variable; otherwise, I'll subtract
}
const options = {
filterType: 'dropdown',
pagination: false,
onRowsSelect: handleRowSelect
};
...
<MUIDataTable
title={"Payments"}
data={credits}
columns={columns}
options={options}
/>
【问题讨论】:
标签: reactjs mui-datatable