Tabulator DataTreeExpanded

Viewed 203

How can I change the level of dataTreeStartExpanded (row,level) function of tabulator at run-time?

I want to change the level of Expand of Tree Elements via inputs from user. So I am looking to set the Option dataTreeStartExpanded "level" at run time post initialization of the table.

Is there anyway I can do it beside re-initializing the table.

1 Answers

You cannot change the dataTreeStartExpanded property once the table has been instantiated.

This leaves you two options, either you pass in a function to this that then calls an external function that you replace at any point:

var externalFunc = function(row, level){
     return true;
}

var table = new Tabulator("#example-table", {
    dataTree:true,
    dataTreeStartExpanded:function(row, level){
        return externalFunc(row, level);
    },
});

Or you can destroy the table, and then reinstatiate it with the new function:

table.destroy();
Related