onscroll event (Grid)
The onscroll event activates when the user scrolls the grid's vertical scrollbar. Â The row variable is passed to the event to provide the current top row of the grid.
Example:
The following event ties the vertical scrolling of one grid to another, so that they scroll together.
onscroll: getObj("related_grid_id").grid.scrollToRow(row);
*Note that the 'scrollToRow' API shown in the example above is not meant to be used to link multiple grids' scrolling action together. For example, you should not use the scrollToRow() API on Grid1 that links to Grid2, and then use the API on Grid2 that links back to Grid1. The scrollToRow() API fires the 'onscroll' event, so trying to use this on multiple grids on one screen will result in an endless loop. This causes undesirable results when attempting to scroll your grid in your application. This API can be used to scroll multiple grids at one time, but should only be used in the 'onscroll' event of one grid. See the below image as an example:Â
Here, there are two separate grids on the screen. Notice that the grid on the left has no scrollbar. The grid on the right is placed inside of a simple container layout with the 'overflow x' property set to 'scroll' so that it can be scrolled left and right. To make the up/down scrollbar work for both of the grids at the same time, we used the scrollToRow() API in the right grid's 'onscroll' event:
getObj("leftGrid").grid.scrollToRow(row);
With "leftGrid" being the ID of the grid on the left side. This way, you can scroll both grids simultaneously using the up/down scrollbar on the right side.Â