有没有一种方法可以在不重新创建制表器的情况下打开/关闭行可选选项



title几乎说明了这一点,我有一些用户可以选择不同的角色,我需要根据他们选择的角色打开/关闭行选择功能,这可能吗?或者你必须重新创建制表器来更改这个值吗?

一旦表被实例化,此选项就不可切换,但您可以使用"选择资格"功能来确定行当前是否应是可选的:

var table = new Tabulator("#example-table", {
selectableCheck:function(row){
//row - row component
return row.getData().age > 18; //allow selection of rows where the age is greater than 18
},
});

您可以调整上面的例子来查看全局布尔值,您可以切换该布尔值来确定表是否可选择

在这里,我只能选择名称为Oli Bob的行参见文档

根据您的方便使用

selectableCheck:function(row){
//row - row component
return row.getData().age > 18; //allow selection of rows where the age is greater than 18
},

const tabledata = [{
name: "Oli Bob",
location: "United Kingdom",
gender: "male",
col: "red",
dob: "14/04/1984"
},
{
name: "Oli Bob",
location: "United Kingdom",
gender: "male",
col: "red",
dob: "14/04/1984"
},
{
name: "Jamie Newhart",
location: "India",
gender: "male",
col: "green",
dob: "14/05/1985"
}
];
let selectable = false;
const table = new Tabulator("#example-table", {
data: tabledata,
selectable: true,
selectableCheck: function(row) {
const name = row.getData().name;
return name === "Oli Bob";
},
columns: [{
title: "Row Num",
formatter: "rownum"
},
{
title: "Name",
field: "name",
width: 200
},
],
});
<script src="https://unpkg.com/tabulator-tables@4.4.3/dist/js/tabulator.min.js"></script>
<link href="https://unpkg.com/tabulator-tables@4.4.3/dist/css/tabulator.min.css" rel="stylesheet" />
<div id="example-table"></div>

相关内容

最新更新