Angularjs ui-grid onRegisterApi event

can someone explain to me what is the goal of gridApi in ui-grid and the purpose of the onRegisterApi event? And what is the order of events when rendering the grid?

+5
source share
2 answers

Here are the docs , and here's a quick run:

GridApi provides the ability to log public method events within the grid and allow other components to use api through featureName.raise.methodName and featureName.on.eventName(function(args){}) . To listen for events, you must add a callback to gridOptions.onRegisterApi

So basically you need to provide a callback for each of the events you want to listen to.

About your second question, the order of events when rendering. Events do not matter, since at this stage you register only for the events that you want to process.

Here are some examples that might help you understand: http://jsfiddle.net/user/relly/fiddles/

+7
source

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

+3
source

Source: https://habr.com/ru/post/1239085/


All Articles