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
559 views
in Technique[技术] by (71.8m points)

javascript - Tabulator: Fix position of right most column when adjusting table column width

How do i fix the position of the right most column?

When trying to increase or decrease the size of a column, the right most column moves along with the adjustment, creating a gap or a horizontal scroll bar in the process. Is there a way to adjust all the columns dynamically to allow the position of the right most column to stay fixed?

Here are a few examples from the docs

Gap from decreasing 3rd column width: Gap from decreasing column width

Scroll bar from increasing 3rd column width: scroll bar from increasing column width

question from:https://stackoverflow.com/questions/65625755/tabulator-fix-position-of-right-most-column-when-adjusting-table-column-width

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

1 Answer

0 votes
by (71.8m points)

Layout Mode

If you want columns to resize then you should look at using the fitColumns layout mode. in the table constructor you should set this on the layout option:

var table = new Tabulator("#example-table", {
    layout:"fitColumns",
});

This can be seen on the Fit To Width Example

Tabulator provides many options for configuring this layout mode to choose how to resize each column. More info on this can be found in the Layout Documentation

Frozen Columns

If you would alternatively like the column to remain where it is, even when the table is scrolled horizontally then you can use the frozen property on the column definition for the dob column to freeze it in place:

{title:"Date of Birth", field:"dob", frozen:true}}

More details on this can be found in the Frozen Columns DOcumentation


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

...