在某些情况下我需要禁用/启用输入某些列的功能,我可以使用制表符吗? 当我打开带有某种状态(布尔值或其他状态)的表的页面时,可用或锁定的列可供输入。谢谢。
示例:
//define some sample data
var tabledata = [{
id: 1,
name: "Oli Bob",
age: "12",
col: "red",
dob: ""
},
{
id: 2,
name: "Mary May",
age: "1",
col: "blue",
dob: "14/05/1982"
},
{
id: 3,
name: "Christine Lobowski",
age: "42",
col: "green",
dob: "22/05/1982"
},
{
id: 4,
name: "Brendon Philips",
age: "125",
col: "orange",
dob: "01/08/1980"
},
{
id: 5,
name: "Margret Marmajuke",
age: "16",
col: "yellow",
dob: "31/01/1999"
},
];
var table_3 = new Tabulator("#table_3", {
height: 205,
data: tabledata,
layout: "fitColumns",
columns: [{
title: "Name",
field: "name",
width: 150,
editor: "input"
},
{
title: "Age",
field: "age",
align: "left",
formatter: "progress",
editor: "input"
},
{
title: "Favourite Color",
field: "col",
editor: "input"
},
{
title: "Date Of Birth",
field: "dob",
sorter: "date",
align: "center",
},
],
});
在某些情况下如何禁用“编辑器:“输入””?
答案 0 :(得分:0)
您可以将回调传递给列定义中的 可编辑 选项,它将为正在编辑的单元格传递Cell Component。
然后您可以返回(ProjectName)build service (OrgName)
来允许编辑,或者返回true
来拒绝编辑:
false
///define editor
var editCheck = function(cell){
//cell - the cell component for the editable cell
//get row data
var data = cell.getRow().getData();
return data.age > 18; // only allow the name cell to be edited if the age is over 18
}
详细信息可以在Edit Documentation
中找到