Skip to content

Commit

Permalink
docs(GridApi) Improve docs and add example on how to subscribe to events
Browse files Browse the repository at this point in the history
  • Loading branch information
swalters committed Dec 2, 2014
1 parent 47ac609 commit ba6be29
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/js/core/factories/GridApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@
* @ngdoc function
* @name ui.grid.class:GridApi
* @description GridApi provides the ability to register public methods events inside the grid and allow
* for other components to use the api via featureName.methodName and featureName.on.eventName(function(args){}
* for other components to use the api via featureName.raise.methodName and featureName.on.eventName(function(args){}.
* <br/>
* To listen to events, you must add a callback to gridOptions.onRegisterApi
* <pre>
* $scope.gridOptions.onRegisterApi = function(gridApi){
* gridApi.cellNav.on.navigate($scope,function(newRowCol, oldRowCol){
* $log.log('navigation event');
* });
* };
* </pre>
* @param {object} grid grid that owns api
*/
var GridApi = function GridApi(grid) {
Expand Down Expand Up @@ -80,7 +89,7 @@
* @methodOf ui.grid.core.api:PublicApi
* @description Returns all visible rows
* @param {Grid} grid the grid you want to get visible rows from
* @returns {array} an array of gridRow
* @returns {array} an array of gridRow
*/
this.registerMethod( 'core', 'getVisibleRows', this.grid.getVisibleRows );

Expand All @@ -93,9 +102,9 @@
* to say which rows changed (unlike in the selection feature).
* We can plausibly know which row was changed when setRowInvisible
* is called, but in that situation the user already knows which row
* they changed. When a filter runs we don't know what changed,
* they changed. When a filter runs we don't know what changed,
* and that is the one that would have been useful.
*
*
*/
this.registerEvent( 'core', 'rowsVisibleChanged' );
};
Expand Down Expand Up @@ -157,7 +166,8 @@
* @ngdoc function
* @name registerEvent
* @methodOf ui.grid.class:GridApi
* @description Registers a new event for the given feature
* @description Registers a new event for the given feature. The event will get a
* .raise and .on prepended to it
* @param {string} featureName name of the feature that raises the event
* @param {string} eventName name of the event
*/
Expand Down

0 comments on commit ba6be29

Please sign in to comment.