Tabulator: formatter:"link" 防止 mutator 来自 运行

Tabulator: formatter:"link" prevents mutator from running

对使用制表符还很陌生,但我真的很喜欢它,因为我到目前为止所看到的。不幸的是,我遇到了以下问题: 我想计算每一行中某些单元格的总和。通过使用突变器实现了这一点。此外,在用户使用带有函数 row.update() 的 cellEdited 编辑单元格后,也会触发增变器。一切正常,直到我将格式化程序:“link”添加到其中一列。 link 代以某种方式阻止了增变器工作。我认为这与回调的顺序有关,但由于我对 tabulator 和 js 还略知一二,所以这只是一个猜测。

这是我的(缩写)table-生成器:

var table
var tabledata = table_data
var choices = [0, 1, 2, 3]
var getUrl = function(cell){
             var url_id = cell.getRow().getCell('id').getValue();
             return "/xyz/" + url_id
           }
var customMutatorSumCur = function(value, data, type, params, component){
        return data.knowledge + data.commitment;
    }
table = new Tabulator(
      "#ratings-table",
      {
        selectable:false,
        layout:"fitDataTable",
        data:tabledata,
        columns:[
          {title:"id", field:"id", visible:false},
          {title:"Name", field:"name", formatter:"link", formatterParams:{
             labelField:"name",
             url:getUrl,
          }},
          {title:"Knowledge", field:"knowledge", editor:"select", editorParams:
{values:choices}, cellEdited:function(cell){
cell.getRow().update({points_cur:true})}},
         {title:"Commitment", field:"commitment", editor:"select", editorParams:{values:choices}, cellEdited:function(cell){
cell.getRow().update({points_cur:true})},
         {title:"Points", field:"points_cur", mutator:customMutatorSumCur},
        ],
    );

生成的 link 工作正常,字段“Points”中的值一开始是正确的,但在单元格编辑时未更新。如果我省略这部分:

, formatter:"link", formatterParams:{
           labelField:"name",
           url:getUrl,

“点数”值在每次单元格编辑后都会正确更新,但当然我不再有 link。 也许有人可以指出我犯错的正确方向并帮助我找到解决方案...

此致, 罗马

格式化程序永远不会阻止来自 运行 的修改器,它们是完全独立的系统,只要单元格中的值已更新,格式化程序就会被调用。

您遇到的问题是,只有在列的值更新时才调用增变器,在这种情况下,您的变化列是从其他两个列获取其值的,因此当这些列更新时,变化的值不是因为没有再次调用增变器。

我建议在 nameknowledge 列的 cellEdited 函数的行中调用 update 函数,这将重新触发增变器:

cell.getRow().update({"points_cur":true})

另请注意,这一行有点不必要,您不需要检索单元格来获取数据:

cell.getRow().getCell('id').getValue();

应该是:

cell.getData().id;