在制表符中,如何为 Select 编辑器设置单元格级别配置?
In tabulator, how do you set cell level configuration for Select editor?
我有一个 select 编辑器用于制表符 table 中的一列。但是,我想专门为同一列中的一个单元格禁用编辑器。有什么配置吗?
columns: [
{ title: "name", field: "name" },
{ title: "date", field: "gender" },
{title: "gender", editor: "select", editorParams: {
values: gender
}
}]
如果您特别想在某些情况下阻止编辑,那么您可以将回调传递给 editable 函数,该函数应该 return true
当单元格可编辑时 false
当单元格不可编辑时
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
}
//in your column definition for the column
{title:"Name", field:"name", editor:"input", editable:editCheck}
如果您更具体地想要更改每个单元格传递给编辑器的参数,那么您可以将函数传递给 editorParams应该 return params 对象的列定义 属性,在创建编辑器之前调用此函数
//define lookup function
function paramLookup(cell){
//cell - the cell component
//do some processing and return the param object
return {param1:"green"};
}
//column definition
{title:"Rating", field:"rating", editor:"star", editorParams:paramLookup}
有关所有编辑功能的详细信息,请参见 Editing Documentation
我有一个 select 编辑器用于制表符 table 中的一列。但是,我想专门为同一列中的一个单元格禁用编辑器。有什么配置吗?
columns: [
{ title: "name", field: "name" },
{ title: "date", field: "gender" },
{title: "gender", editor: "select", editorParams: {
values: gender
}
}]
如果您特别想在某些情况下阻止编辑,那么您可以将回调传递给 editable 函数,该函数应该 return true
当单元格可编辑时 false
当单元格不可编辑时
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
}
//in your column definition for the column
{title:"Name", field:"name", editor:"input", editable:editCheck}
如果您更具体地想要更改每个单元格传递给编辑器的参数,那么您可以将函数传递给 editorParams应该 return params 对象的列定义 属性,在创建编辑器之前调用此函数
//define lookup function
function paramLookup(cell){
//cell - the cell component
//do some processing and return the param object
return {param1:"green"};
}
//column definition
{title:"Rating", field:"rating", editor:"star", editorParams:paramLookup}
有关所有编辑功能的详细信息,请参见 Editing Documentation