javascript - 使用制表符 selectRow 方法以编程方式选择行

标签 javascript tabulator

我正在使用制表器在我的网站上创建表格。我可以通过单击行来选择行,也可以使用 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/

相关文章:

javascript - jQuery 正则表达式测试

tabulator - 如何在最新版本的制表符中重新初始化数据表

javascript - 从制表器中的 json 加载数据?

javascript - API数据未显示在表中,需要显示进度加载(延迟加载)

tabulator - 如何在制表符中创建多选标题过滤器?

javascript - Angular js 中的指令无法正常工作

javascript - 将父组件的属性传递给 Vue 中所有嵌入的子组件

javascript - 居中元素

javascript - 从与 JavaScript 中的字符串匹配的数组中删除多个项目

制表符表格列的大小未正确调整