Scrollx: move to a specific column

Scrollx: move to a specific column

mzardmzard Posts: 11Questions: 4Answers: 0

Hi,
I have a table with years and months columns, I've set the fixedeader and the scrollx features, and I'd like that the table "focus" is on the current month (so the user doesn't have to move the horizontal scroller to it).
Is that possible?
Thanks in advance

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • mzardmzard Posts: 11Questions: 4Answers: 0

    Link to test case: http://live.datatables.net/wegeqome/1/
    Description of problem: If the screen is small, the last column (in this case Salary) is not visible. I'd like to automatically scroll to the right to make the column visible (so the user doesn't have to do it manually).

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394

    Use the Responsive extension.
    https://datatables.net/extensions/responsive/

  • mzardmzard Posts: 11Questions: 4Answers: 0

    The user need to see all columns and want the possibility to scroll horizontally (so I use the scrollx feature and it's fine for this purpose). But they also want to focus the table at specific column, so I need to automatically scrolling the table horizontally to make that columns visible (so the user doesn't have to do it manually).

  • kthorngrenkthorngren Posts: 20,141Questions: 26Answers: 4,736
    edited January 2021 Answer ✓

    See if this thread helps. If not please update your test case with what you tried and give us the new link.

    Kevin

  • mzardmzard Posts: 11Questions: 4Answers: 0

    Yes, it helped. At the end I've used something like this:

    $('div.dataTables_scrollBody').animate({scrollLeft: rightPos},1000);
    

    Thanks!

This discussion has been closed.