【发布时间】:2019-11-12 07:05:24
【问题描述】:
我需要选择父行并禁用子行的选择。我正在使用带有复选框formatter 选项的可选行进行行选择。我尝试使用selectableCheck,但它不适用于勾选formatter。
任何帮助将不胜感激。 请找到类似的代码框链接:我想禁用子元素的行选择复选框。
JSX
class Home extends Component {
render() {
const columns = [
{
formatter: "rowSelection",
titleFormatter: "rowSelection",
align: "center",
headerSort: false,
cellClick: function(e, cell) {
cell.getRow().toggleSelect();
console.log(cell.getRow(), cell.getRow().getTreeParent());
}
},
{ title: "Name", field: "name", width: 200 },
{ title: "Location", field: "location", width: 150 },
{ title: "Gender", field: "gender", width: 150 },
{ title: "Favourite Color", field: "col", width: 150 },
{
title: "Date Of Birth",
field: "dob",
align: "center",
sorter: "date",
width: 150
}
];
let data = [
{
name: "Oli Bob",
location: "United Kingdom",
gender: "male",
col: "red",
dob: "14/04/1984",
_children: [
{
name: "Mary May",
location: "Germany",
gender: "female",
col: "blue",
dob: "14/05/1982"
},
{
name: "Brendon Philips",
location: "USA",
gender: "male",
col: "orange",
dob: "01/08/1980",
_children: [
{
name: "Margret Marmajuke",
location: "Canada",
gender: "female",
col: "yellow",
dob: "31/01/1999"
},
]
}
]
},
{
name: "James Newman",
location: "Japan",
gender: "male",
col: "red",
dob: "22/03/1998"
}
];
let options = {
layout: "fitColumns",
dataTree: true,
dataTreeStartExpanded: true,
dataTreeElementColumn: "name"
};
return (
<ReactTabulator
ref={ref => (this.ref = ref)}
data={data}
columns={columns}
tooltips={true}
options={options}
/>
);
}
}
export default Home;
【问题讨论】:
-
显示你的代码?
-
@blueseal 我已在代码框链接上方添加
标签: javascript reactjs treeview jsx tabulator