5

So I'm trying to get my Angular UI Grid to register a double click event on an entire row to open up a modal. I can start with a toastr toast and go from there though. This is the closest I've come based on various demos and examples online, but I just can't seem to get it to work.

Controller:

$scope.gridHandlers = {
  onDblClick: function(rowItem){
    toastr.success(rowItem, 'Row Item:')
  }
}
$scope.gridOptions = {
  onRegisterApi : function(gridApi){
    $scope.gridApi = gridApi
  },
  data: $scope.customerList,
  enableRowHeaderSelection: false,
  enableRowSelection: true,
  enableSelectAll: false,
  multiSelect: false,
  noUnselect: true,
  rowTemplate: '<div ng-dblclick="getExternalScopes().onDblClick(row)" external-scopes="gridHandlers" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name\" class=\"ui-grid-cell\" ng-class=\"{ \'ui-grid-row-header-cell\': col.isRowHeader }\" ui-grid-cell></div>',
  columnDefs : [
  {name: 'name', type: 'string'},
   ...etc
  {name: 'status_name', displayName: 'Status', width: '11%', type: 'string'}
]

View:

<div class="large-12 cols" ui-grid="gridOptions" ui-grid-selection external-scopes="gridHandlers">

I've tried using the grid.appScope methods they talk about and everything else, but I just can't get it to work. Where am I here, totally off?

1 Answer 1

7

grid.appScope did work for me. Please see the plnkr (Double click on any row to see the row data)

Sign up to request clarification or add additional context in comments.

1 Comment

I know this is an older post. but anyways, i followed your guide (which worked, thanks!!!), but I lost a piece of functionality, due to the way the row template was set up. Now, when I click the 'check' at the left of the grid, the row no longer highlights. Did you experience something similar?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.