首页 > 解决方案 > 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(","));

                }
            }
        ]

扩展的行为很奇怪:

有谁知道如何以另一种方式获取选定的行?

标签: javascriptdatatables

解决方案


推荐阅读