How to fix the left and right scroll bars of element ui table components at the bottom?

problem: currently using the table component of element ui, but due to too many columns, the official does not support adaptive width, but there will always be left and right scroll bars, which leads to the problem that data modification must first be scrolled to the following scroll bar, and then data view and data modification is extremely inconvenient!

clipboard.png

1. First of all, is there any way to solve the problem of adaptation, and to ensure that the text of some columns (the following box) is not blocked
2. Second, I hope there is a solution that can fix the left and right scroll bars at the bottom of the screen

look forward to your reply


  let el = document.getElementsByClassName("el-table")[0];
  this.$nextTick(() => {
    el.scrollLeft = 1000000;//
  }, 10);
  

width is not adaptive. Writing 100% is calculated automatically, and if you assign a value to certain widths, these widths add up to exceed the width of the parent element before a horizontal scroll bar appears.
height is not adaptive. If you want to see the scroll bar all the time, write the dead height, or the parent element writes dead, and the table height is 100%. In this way, a horizontal scroll bar will appear if the width is not enough, and the meter head can be fixed at the same time. But in this way, the vertical scroll bar is displayed in the table.
has not been in touch with this for a long time. I hope it will be helpful to you. I'm going to be driven crazy by this table, too. I feel bad


use max-height to limit the maximum height. How is it possible? calculate the height occupied by table yourself. In created:

// this.clientHeight-
this.clientHeight = document.body.clientHeight - 299

on el-table:

:max-height="clientHeight"

this is equivalent to being fixed in a space at the height of the screen, and when there is a lot of data, you don't have to drag to the bottom to see the scroll bar.


limit the maximum height with max-height. Try


to return too much data. It is recommended to use paging, otherwise the display interaction will be very poor. Every time you have to drop down the scroll bar in the horizontal scroll bar.
the horizontal scroll bar in the table component. Because there are too many columns, even if you set max-width, for each column, there will still be a scroll bar, so you can't remove the scroll bar below. The limit of element-ui

Menu