can someone explain me what is purpose of gridApi in ui-grid and purpose of onRegisterApi event? And what is order of event when grid is rendering?
Here's the docs, and here's a quick run-down:
GridApi provides the ability to register public methods events inside the grid and allow for other components to use the api via
featureName.raise.methodName
andfeatureName.on.eventName(function(args){})
. To listen to events, you must add a callback togridOptions.onRegisterApi
So basically you need to provide a callback for each of the events that you want to listen on.
About your second question, the order of events when the gird is rendering. The of events doesn't matter since in this phase you only register to the events that you want to handle.
Here are couple of examples that might help you understand: http://jsfiddle.net/user/relly/fiddles/
Basically all data used to display the grid is stored in gridApi which enables you to manipulate the grid properties and content in your script.
onRegisterApi is used to handle events. For example: If an edit is made, or a row is selected, you would use the onRegisterApi to catch the event and run some function.
As for ordering, it doesn't matter if your gridOptions are created first, or the html DOM element. What is important is that when you initialize your grid, the variables you use in the gridOptions (eg: data) are initialized before the gridOptions.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With