fin-hypergrid / core

A canvas-based super high performant grid renderer API
MIT License
896 stars 144 forks source link

Scrolling from bottom to top #740

Open giok1992 opened 6 years ago

giok1992 commented 6 years ago

Hello,

We’re trying to develop an order book for trading, and we are using two tables. One for buy orders and another for sell orders.

Here is a screenshot of an example:

https://puu.sh/AUM2i/4976cd00aa.png

The buy table scrolls down as normal, as it starts from lowest price down to the highest price.

The sell table should scroll from bottom (low price) to the top (high price).

Can anyone suggest a method of making the scroll being opposite, instead of scrolling down, for it to start at the bottom and allow scrolling up?

Thanks

joneit commented 6 years ago

Are you merely asking how to programmatically set the scroll position to an arbitrary position?

giok1992 commented 6 years ago

Not just to set at an arbitrary position, but rather make that the default position. So let’s say it’s set at the very bottom of the table, if a new item is added to the very bottom, the scroll bar should not move up, but rather stay at the very bottom.

joneit commented 6 years ago

to set scroll to bottom after setting up grid data:

grid.setData(....); // or however you're setting up your grid data
grid.setVScrollValue(Infinity);

after doing your add row (however you're doing it):

// add row here
grid.synchronizeScrollingBoundaries();
grid.setVScrollValue(Infinity);
giok1992 commented 6 years ago

Hello joneit,

We have been trying to implement your solution but we can't get it to work:

grid.setVScrollValue(Infinity);

Here is the code we're using:

grid.setData(data); grid.setScrollingNow(true); grid.setVScrollValue(Infinity); grid.setVScrollbarValues(Infinity);

It doesn't seem to do anything on our end, and it doesn't throw an error either.

We had no luck using absolute values either.

joneit commented 5 years ago

I played with this some more and confirmed that grid.setVScrollValue(Infinity) is not reliable. Use the following alternative (at least until the other solution is fixed):

grid.sbVScroller.index = grid.sbVScroller.range.max;

I will keep this ticket open.