Skip to content

setColumns problem when dataTree:true and first column field in Tabulator.data is undefined #4875

@RDamman

Description

@RDamman

Describe the bug
setColumns problem when dataTree:true and first column field in Tabulator.data is undefined. After calling setColumns an error occurs and the Tabulator is in a strange state.

To Reproduce
Start my fiddle and press the button "Change columns"

Expected behaviour
You get the expected behaviour when you change
in var tableColums1
{title:"Name", field:"name2", width:200, editor:"input"},
into:
{title:"Name", field:"name", width:200, editor:"input"},

Desktop:
Browser [latest Chrome and Firefox on Windows 10]

https://jsfiddle.net/nfs8uy4q/14/

<script type="text/javascript" src="https://unpkg.com/tabulator-tables@6.4.0/dist/js/tabulator.js"></script>

.tabulator{
background-color:#f3f3ff;
}

//Sample Data
var tableData = [
{id:1,name:"Bob", n:21, _children:[{id:10,name:"Bob1", n:22},{id:11,name:"Bob1", n:22}]},
{id:2,name:"Steve", n:23, _children:[{id:20,name:"Steve1", n:22},{id:21,name:"Steve1", n:22}]},
{id:3,name:"Jim", n:50},
]

var tableColums1 = [
{title:"ID", field:"id", width:200, visible:false},
{title:"Name", field:"name2", width:200, editor:"input"},
{title:"Amount", field:"n", width:50, editor:"input"},]

var tableColums2 = [
{title:"ID", field:"id", width:200, visible:false},
{title:"Name", field:"name", width:200, editor:"input"},
{title:"Amount", field:"n", width:50, editor:"input"},
]

//Example Table
var table = new Tabulator("#table", {
data:tableData, //load data into table
height:200, //enable the virtual DOM
dataTree:true,
columns:tableColums1
});

function changeColumns()
{
table.setColumns(tableColums2);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Possible BugA possible bug that needs investigation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions