selecting all check boxes inside ng-grid

Wednesday, July 9, 2014

I found some jsfiddle jquery code and tried to combine it with my ng-grid to select all check boxes within the grid. However, it is not working.


Here is a quickmock up of what i tried to do:


http://ift.tt/1k4HdLD


this is my directive



(function(){
var app = angular.module('provider-selectall', []);
app.directive('selectAll',function(){
return{
restrict: 'A',
link: function(scope,element,attr){
element.click(function() {
$('.ngSelectionCheckbox input[type="checkbox"]').prop('checked', true);
});
}
};
});
})();


the button that will activated by the directive



<div class="btn-group">
<button class="my-btn btn-info" select-all>Select All</button>
</button>
</div>


stuff within my ng-grid controller



var checkBoxCellTemplate = '<div class="ngSelectionCell"><input tabindex="-1" class="ngSelectionCheckbox" type="checkbox" ng-checked="row.selected" /></div>';
$scope.gridOptions = {
columnDefs: [
{
cellTemplate: checkBoxCellTemplate,
showSelectionCheckbox: true
},{
field: 'name',
displayName: 'CPT Code/Description'
},{
field: 'cash_price',
displayName: 'Cash Price'
},{
field: 'average_price',
displayName: 'Average Price'
},

],
data: 'provider_medical_services'


original jsfiddle code:



$('#toggle-all').click(function() {
$('.btn-group input[type="checkbox"]').prop('checked', true);
});






http://ift.tt/1w05HLE