制表符 - 在单击事件时获取另一个单元格的值
Tabulator - get another cell's value on click event
这个对于制表专家来说应该很简单(但对我来说不是)...
我有一个制表符table。我制作了一列,“编辑”可点击,如下所示。它工作正常并且 returns 是我单击的单元格的值。但是,这不是我需要的。我需要获取同一行(“transactionID”列)中另一个单元格的值。我知道你会如何用其他语言做到这一点,只需使用 x 和 y 值移动 3 列并获取值。但它是如何在制表符中完成的?通过列名?我找不到关于如何完成此操作的任何示例代码。
这是我的制表符初始化中的片段:
{title:"edit" , name:"edit", formatter:myformatter, cellClick:function(e, cell){alert("cell clicked - " + cell.getValue())}},
我只需要为“transactionID”而不是“edit”设置 return 值
在有人问之前,不,我不能只让“transactionID”可点击。我需要将可点击的单元格分开。
感谢您的帮助!
好的,因为我没有得到这个问题的答案,所以我苦苦思索,最终自己弄明白了。为了节省其他人将来 运行 的时间,我发布了我是如何解决它的。带有以下注释的代码:
// this goes in your tabulator column definitions. In my example, "edit" is a column
with an image button that on clicking, redirects to another page depending on what cell was clicked
{title:"" , name:"edit", formatter:openIcon, headerSort:false, cellClick:function(e, cell){
var re = cell.getRow(cell); // get the row of the cell that was clicked
var thenum = re.getData().id; // gets the value of column "id" in the same row
var theurl = "editTransaction.php?trans="+thenum; // creates my url
console.log(theurl); // perform whatever action you need to do. replace this.
}},
这个对于制表专家来说应该很简单(但对我来说不是)...
我有一个制表符table。我制作了一列,“编辑”可点击,如下所示。它工作正常并且 returns 是我单击的单元格的值。但是,这不是我需要的。我需要获取同一行(“transactionID”列)中另一个单元格的值。我知道你会如何用其他语言做到这一点,只需使用 x 和 y 值移动 3 列并获取值。但它是如何在制表符中完成的?通过列名?我找不到关于如何完成此操作的任何示例代码。
这是我的制表符初始化中的片段:
{title:"edit" , name:"edit", formatter:myformatter, cellClick:function(e, cell){alert("cell clicked - " + cell.getValue())}},
我只需要为“transactionID”而不是“edit”设置 return 值
在有人问之前,不,我不能只让“transactionID”可点击。我需要将可点击的单元格分开。
感谢您的帮助!
好的,因为我没有得到这个问题的答案,所以我苦苦思索,最终自己弄明白了。为了节省其他人将来 运行 的时间,我发布了我是如何解决它的。带有以下注释的代码:
// this goes in your tabulator column definitions. In my example, "edit" is a column
with an image button that on clicking, redirects to another page depending on what cell was clicked
{title:"" , name:"edit", formatter:openIcon, headerSort:false, cellClick:function(e, cell){
var re = cell.getRow(cell); // get the row of the cell that was clicked
var thenum = re.getData().id; // gets the value of column "id" in the same row
var theurl = "editTransaction.php?trans="+thenum; // creates my url
console.log(theurl); // perform whatever action you need to do. replace this.
}},