Horizontal scroll on desktop devices

Horizontal scroll on desktop devices

DanielADDanielAD Posts: 4Questions: 2Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: I have multiple tables with different number of columns so i cant use css. I need to make table to show all columns on resolutions above eg. 1440px and to have horizontal scrolling. On mobile and tablet screen sizes responsive feature should be enabled.

Answers

  • kthorngrenkthorngren Posts: 21,722Questions: 26Answers: 5,027
    edited 12:04AM

    scrollX takes a boolean value. A simple Responsive setting takes a boolean value too. Before initializing Datatales check for the screen resolution - possibly the options in this SO thread will work. Then set the scrollX and responsive boolean values appropriately. If you have a more complicated responsive setting then try something like this pseudo code:

    let responsive = false;
    let scrollX = true;
    if ( screenResolution < 1440 ) {
      responsive = { .... };  // All the config options
      scrollX = false;
    }
    
    new DataTable('#example', {
        // Rest of datatables config options
        responsive: responsive,
        scrollX: scrollX
    });
    

    Kevin

Sign In or Register to comment.