Accessing elements in header cell template

372 Views Asked by At

This is one field in the andular 1 ui-grid

 {
          name: 'refer',
          field: 'refer',
          displayName: 'Refer', enableSorting: false, headerTooltip: 'Refer',
          headerCellTemplate: ' ' +
          '<div class="padding5"> Refer <input value=0 type="checkbox" ng-model=\'referAll\' ng-click="grid.appScope.referAllOrder(referAll)"></div>',
          cellTemplate: '<div  class="text-center" ng-if="grid.appScope.checkReferred(row) == null"> <input type="checkbox" ng-model="row.entity.isReferred"/> </div>' +
          '<div class="text-center" ng-if="grid.appScope.checkReferred(row) != null">  <i ng-click="grid.appScope.cancelReferral(row.entity.visitMasts[0])" role="button" class="colorRed fa fa-close icon-red"></i></div>'
        }

Is there any way, I can control the check box in header cell template, here its referAll ?. Here I need to unselect the check box in some scenarios, like page reload.

Tried but not working, "vm.gridOptions1.columnDefs[10].headercellTemplate.referAll = true"

1

There are 1 best solutions below

2
On BEST ANSWER

I'm not sure what you're trying to achieve here, but changing the ng-model from \'referAll\' to \'grid.appScope.referAll\' would allow you to access the value from within the headerCellTemplate.

Assuming you have defined referAll, you could then assign referAll = true or false to check / uncheck the checkbox.