Basically, all the data used to display the grid is stored in gridApi, which allows you to control the properties and contents of the grid in a script.
onRegisterApi is used to handle events. For example: if editing is done or a line is selected, you must use onRegisterApi to catch the event and run some function.
As for ordering, it doesn't matter if your gridOptions or html DOM element are created. The important thing is that when you initialize your grid, the variables that you use in gridOptions (for example: data) are initialized before gridOptions.
Hope this helps
source share