我正在使用制表器在我的网站上创建表格。我可以通过单击行来选择行,也可以使用 tabulator.selectRow() 方法选择所有行。
According to the documentation :
To select a specific row you can pass the any of the standard row component look up options into the first argument of the function.
我已经见过几次了,但没有有效的例子。有谁知道需要如何提供行组件查找选项?
假设我有一些带有名称字段的行。
我想选择 name == 'dennis' 的行。
文档建议我可以在 selectRow() 参数中传递查找选项。只是没有示例或任何指示来说明参数的预期语法。
我目前的工作方式如下,这似乎不是最直观的方式。
table.getRows().forEach(row => {
if (row.getData().name == 'dennis') row.toggleSelect();
});
或者像这样:
params.layer.tableView.table.getRows()
.filter(row => row.getData().name == 'dennis')
.forEach(row => row.toggleSelect());
最佳答案
我最终在 github 的帮助下到达了那里。 #1749
为我解决这个问题的是:
Any function that takes a component as an argument will also attempt to find that component based on the value provided if it is not a component itself.
这里作为选择我的行的示例。
table.selectRow(table.getRows().filter(row => row.getData().name == 'Dennis'));
关于javascript - 使用制表符 selectRow 方法以编程方式选择行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54312390/