有没有办法在不重新创建制表符的情况下切换行可选选项 on/off
Is there a way to toggle the row selectable option on/off without recreating the tabulator
title 说得差不多了,我有一些用户可以选择不同的角色,我需要根据他们选择的角色切换行选择功能 on/off,这可能吗,或者你有重新创建制表符以更改此值?
在此我只能 select 名称为 Oli Bob
的行 请参阅 Documentation
根据自己的喜好使用
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>
一旦实例化了 table,此选项就不可切换,但您可以使用 Selection Eligibility 函数来确定该行当前是否应选择 table:
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
},
});
您可以调整上面的示例以查看您切换以确定 table 是否为 selectable
的全局布尔值
title 说得差不多了,我有一些用户可以选择不同的角色,我需要根据他们选择的角色切换行选择功能 on/off,这可能吗,或者你有重新创建制表符以更改此值?
在此我只能 select 名称为 Oli Bob
的行 请参阅 Documentation
根据自己的喜好使用
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>
一旦实例化了 table,此选项就不可切换,但您可以使用 Selection Eligibility 函数来确定该行当前是否应选择 table:
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
},
});
您可以调整上面的示例以查看您切换以确定 table 是否为 selectable
的全局布尔值