Always display vertical scrollbar

Always display vertical scrollbar

johnsonjjohnsonj Posts: 14Questions: 3Answers: 0

Is there a way to display a vertical scrollbar even when the data set is small enough to fit in the defined space? I want a vertical scrollbar all the time on the table. The table will always contain exactly 10 rows of data. The user needs to see all 10 rows at the same time but I need the vertical scrollbar so that the final column (which is fixed) will align with the final column (also fixed) of a separate table directly above it. Since the other table has about 50 rows of data it always has a vertical scrollbar. See attached image.

I define the table that needs the scrollbar this way:

        scrollY: '260px',
        scrollX: true,
        scrollCollapse: true,

I have the following css for the table:

.dataTables_scrollBody{
    height: auto;
    overflow: scroll !important;
}

Replies

  • PaulusPaulus Posts: 69Questions: 17Answers: 5

    How about additional row to the lower table (making it 11 rows) and styling the last row to your taste?

  • allanallan Posts: 61,726Questions: 1Answers: 10,109 Site admin

    DataTables should actually take the scrollbar into account if it is visible. Do you have a link to the page showing the issue or can you use http://live.datatables.net JSBin, JSFiddle etc to create a test case?

    Allan

  • johnsonjjohnsonj Posts: 14Questions: 3Answers: 0

    Here is an example:

    In the example, you can see that I have two fixed columns: the first column and the last column. If I do not make the last column fixed, or if I removed fixed columns altogether, the scrollbar is there. Also, if I make the "scrollY" field smaller (300px) the scrollbar appears. I need that scrollbar to be there at all times and I also need to be able to see all 10 records at all times. What do you think?

    http://live.datatables.net/cuqejovo/1/edit?html,css,js,output

This discussion has been closed.