Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular ui-grid events in cell header not firing

I'm using a headerCellTemplate in the columDefs of my ui-grid (not ng-grid but the new rewrite). In the html I have a checkbox. Essentially I am trying to add a checkbox in the header of a column that is all checkboxes so I can check all/none. The cell renders fine with the checkbox. The problem is that the ng-change in the checkbox in the header never fires the event. Additionally the ng-model value never changes. Looking at the code there is a directive used called uiGridHeaderCell so I have to assume that it is gobbling up my event as well as being in its own scope so it never sets the variable in my scope.

Any way around this? Every example I've come across never has anyone trying to call their own method from within the header (ie calling something outside the scope of the directive).

like image 926
Scott Avatar asked Oct 29 '14 01:10

Scott


Video Answer


2 Answers

External-Scopes is no longer used as of ~3.0.7 Accessing Scope in templates

Now you add grid.appScope like this in your cellTemplate:

ng-click="grid.appScope.myFunction()"
like image 172
Marcus Showalter Avatar answered Oct 02 '22 19:10

Marcus Showalter


When using Angular's controllerAs syntax...

ng-click="grid.appScope.vm.editRow(grid, row)"

example: http://plnkr.co/edit/D48xcomnXdClccMnl5Jj?p=preview

like image 35
Homer Avatar answered Oct 02 '22 20:10

Homer