Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
561 views
in Technique[技术] by (71.8m points)

How to get widths of all columns in a Tabulator table?

Is there a way to get the width of all the columns? I was experimenting with this:

var table = new Tabulator("#example-table", {
    columnResized:function(column){
        var columns = table.getColumns()
        for (i = 0; i < columns.length; i++)
        {
            // columns[i].width isn't valid, is there something else that can be used?
        }
    },
});
`
question from:https://stackoverflow.com/questions/65877616/how-to-get-widths-of-all-columns-in-a-tabulator-table

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To get the entire column layout, use:

var columns = table.getColumnLayout()
for (i = 0; i < columns.length; i++)
{
    columns[i].width = ... // or columns[i]["width"]
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...