javascript - 在制表符中动态加载子节点

标签 javascript tabulator

var table = new Tabulator("#view360-table", {
    width:"100%",
    dataTree:true,
    layout:"fitDataFill",
rowContext:function(e, row){
    //e - the click event object
    //row - row component
    alert(row.getIndex());
    },
    dataTreeStartExpanded:false,
    ajaxURL:"http://localhost/JSONNew/rum.json?v="+Math.floor(Math.random()*100000),
    ajaxError:function(xhr, textStatus, errorThrown){
    alert("Sorry Error Loading The Table!");
    },
     dataTreeRowExpanded:function(row, level){
        var index= row.getIndex();
    $.get("http://localhost/JSONNew/id_"+index+".json", function(data, status){        
     var obj = JSON.parse(data);
     alert(data);
      row.update({_children:obj});
    },"text");
    },
    columns:[
    {title:"Name", field:"name", width:200, responsive:0}, 
    {title:"Status", field:"status", align:"center",formatter:"tickCross",formatterParams:{allowEmpty:true},width:150, responsive:0},
    {title:"Acknowledge", field:"ack", align:"center",formatter:"tickCross",formatterParams:{allowEmpty:true}, width:150, responsive:0},
    {title:"Application",columns:[{title:"Application Performance",field:"apperf",formatterParams:{allowEmpty:true} ,align:"center",formatter:"tickCross",width:100,responsive:0}
    ,{title:"Application Availablity", align:"center",formatter:"tickCross",formatterParams:{allowEmpty:true},field:"appavail",width:100,responsive:0}]},
    {title:"Last Status Change",align:"center", field:"statchange", width:200, sorter:"datetime",sorterParams:{allowEmpty:true,format:"DD-MM-YYYY hh.mm AM/PM", alignEmptyValues:"top",},responsive:2},
    ],
}); 

我想在每次伸展树(Splay Tree)时从 URL 加载子节点。但是,由于 dataTreeStartExpanded 设置为 false 并且每次更新后都会重新绘制表格,因此我无法查看子节点并卡在根节点上。是否有办法执行此操作? 提前致谢!

最佳答案

数据树扩展不是异步的,因此当用户扩展树时不可能加载子级,因为在显示子行之前它不会等待 ajax 请求返回。此外,扩展元素仅针对首先具有子项的行显示。

加载数据时,您需要在表中包含子行

关于javascript - 在制表符中动态加载子节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54628752/

相关文章:

javascript - 与 LinkedIn Hopscotch 的元素对齐

javascript - 原型(prototype) - 显示一个元素,隐藏 sibling

javascript - 制表符在运行更改器(mutator)后运行验证器

javascript - 如何从 Internet Explorer 9 创建弹出窗口

javascript - 如何将存储在json文件中的td类获取到html表中(使用ajax)

javascript - Laravel 通知铃

tabulator - 如何设置列的默认颜色?

javascript - 调整不同表格中的制表符行高

制表器计算总价

tabulator - 如何在制表符中过滤树结构中的子项?