javascript - DataTables 的 TreeGrid 扩展 - 获取选定行的值
问题描述
我找到了 DataTables 的 TreeGrid 扩展:
https://homfen.github.io/dataTables.treeGrid.js/
但是当我包含一个按钮来读取选定的行时:
dom: 'Bfrtip',
select:true,
buttons: [
{
text: 'Alert selected',
action: function(e, dt, node, config) {
var data = table.rows({
selected: true
}).data().toArray();
var i;
var text = new Array();
for (i = 0; i < data.length; i++) {
text.push(data[i].name);
}
alert("you selected: " + text.join(",") );
console.log("text---" + text.join(","));
}
}
]
扩展的行为很奇怪:
- 如果我选择一个父级,则所有子级都不再被选中。
有谁知道如何以另一种方式获取选定的行?
解决方案
推荐阅读
- python - 在 Python 中读取文件时从字符串列表中删除 ''\n"
- python - 用 pandas 重新排列列:是否有等效于 dplyr 的 select(..., Everything())?
- android-studio - 如何在没有 StatefulWidget 的情况下使用 setState?
- javascript - 不使用从 fetch 调用返回的数据设置状态
- python - Kivy Python - 使用 kivy.utils.rgba 的颜色错误
- sql - 查询考试成绩计算
- javascript - 如何避免javascript中的小数错误?
- django - UpdateView 创建新对象而不是更改原始对象
- webpack - webpack string 用 jest 替换加载器替代方案
- mysql - 在 MySQL 5.6 中使用 GROUP BY 模拟 LAG