Tabulator getElement 不是函数
Tabulator getElement is not a function
我目前在数组中有一个包含 100 个元素的制表符 table。当我调用函数来抓取特定单元格时,它设法抓取前 25 行并更改我想要的特定单元格的颜色。
问题是当其他一切都一样时,后面的那些并没有改变颜色。我该如何解决?
这是我用来生成背景颜色的代码。它适用于前 25 行,但无法获取接下来的 75 行
var allRowData = table.getRows();
// loops the entire row
allRowData.forEach(x => {
// using the row data, grab the columns and compare with a condition
scope.columns.forEach(y => {
if (y.priority == 3) { // checks for the priority number to add a color to it
var rowCell = x.getCell(`${y.fieldName}`);
rowCell.getElement().style.backgroundColor = "#F00";
}
});
});
您不应尝试从 Tabulator 外部直接操作 table 的布局。
Tabulator 使用虚拟 DOM,这意味着它将根据需要创建和销毁 table 的元素,这意味着您只能设置当前可见的元素的样式,当这些元素是更新任何以前的格式可能会丢失,恕不另行通知。
如果您希望设置单元格元素的样式,您必须在列定义中使用 formatter
函数或在 rows/cells 上调用 table 上的 rowFormatter
函数] 被重新绘制。
中找到有关这些内容的完整详细信息
如果您想根据 table 之外的内容更改行的状态,那么您的格式化程序应该引用这个外部变量,并且当您更新外部状态时,您应该触发 redraw
table 上的函数以重新触发格式化程序
我目前在数组中有一个包含 100 个元素的制表符 table。当我调用函数来抓取特定单元格时,它设法抓取前 25 行并更改我想要的特定单元格的颜色。
问题是当其他一切都一样时,后面的那些并没有改变颜色。我该如何解决?
这是我用来生成背景颜色的代码。它适用于前 25 行,但无法获取接下来的 75 行
var allRowData = table.getRows();
// loops the entire row
allRowData.forEach(x => {
// using the row data, grab the columns and compare with a condition
scope.columns.forEach(y => {
if (y.priority == 3) { // checks for the priority number to add a color to it
var rowCell = x.getCell(`${y.fieldName}`);
rowCell.getElement().style.backgroundColor = "#F00";
}
});
});
您不应尝试从 Tabulator 外部直接操作 table 的布局。
Tabulator 使用虚拟 DOM,这意味着它将根据需要创建和销毁 table 的元素,这意味着您只能设置当前可见的元素的样式,当这些元素是更新任何以前的格式可能会丢失,恕不另行通知。
如果您希望设置单元格元素的样式,您必须在列定义中使用 formatter
函数或在 rows/cells 上调用 table 上的 rowFormatter
函数] 被重新绘制。
如果您想根据 table 之外的内容更改行的状态,那么您的格式化程序应该引用这个外部变量,并且当您更新外部状态时,您应该触发 redraw
table 上的函数以重新触发格式化程序