javascriptscrolldojodgrid

dGrid table scroll horizontally programmatically


Is there a method in dGrid which let's you scroll to a certain column in the table, I have a table which is scrollable horizontally and I want to know if there is possibility to do something like:

myGrid.scrollToColumn(someColumnToScrollTo);

I know I can scroll vertically to some row, is there anything similar for what I need?


Solution

  • As kfranqueiro (Dojo 1.x committer and dgrid maintainer) said here:

    https://github.com/SitePen/dgrid/issues/360

    Firstly, there is a scrollTo method on dgrid instances, which you can pass an object with x or y properties to scroll in a platform-agnostic manner

    still him, here he use that function:

    https://github.com/SitePen/dgrid/issues/1279

    grid.scrollTo({ y: index * grid.get('rowHeight') })

    you need to pass x instead of y and the offset you need instead of index * grid.get('rowHeight')