简体   繁体   English

我可以仅在 Tabulator.js 中加载时扩展一个节点吗?

[英]Can I have expanded one node only on load in Tabulator.js?

I am using nested data trees in Tabulator.js and if I use the option dataTreeStartExpanded:true all nested rows will be expanded.我在 Tabulator.js 中使用嵌套数据树,如果我使用选项dataTreeStartExpanded:true所有嵌套行都将被展开。 I want only one be expanded on load/render?我只想在加载/渲染时扩展一个? Is that possible?那可能吗?

Here is working jsFiddle to play around.这里正在使用 jsFiddle来玩。

I found that there is a div with class tabulator-data-tree-control-expand or tabulator-data-tree-control-collapse .我发现有一个 div 带有 class tabulator-data-tree-control-expandtabulator-data-tree-control-collapse Changing the name in dev tools does nothing.在开发工具中更改名称无济于事。

Currently it looks like目前它看起来像在此处输入图像描述

But I want to be like that after the web page loads但我想在 web 页面加载后成为那样在此处输入图像描述

Maybe I can somehow click the + to expand.也许我可以以某种方式单击+展开。 Tabulator has a listener there Tabulator 那里有一个听众在此处输入图像描述

But I do not know how to call it for that particular +.但我不知道如何为那个特定的 + 调用它。

oh, I found it in documentation .哦,我在文档中找到了。

.. a function that will be passed in a row component and the level of that row in the table (starting at 0), it should return a boolean value to indicate the rows expansion state: .. 将在行组件中传递的 function 和表中该行的级别(从 0 开始),它应该返回一个 boolean 值以指示行扩展 Z9ED39E2EA931586B576A985A69EZ2:

var table = new Tabulator("#example-table", {
    dataTree:true,
    dataTreeStartExpanded:function(row, level){
        return row.getData().driver; //expand rows where the "driver" data field is true;
    },
});

and then in data you have to use new property driver:true然后在数据中你必须使用新的属性driver:true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM