jeudi 17 novembre 2016

Edit all cells in a column in ng-handsontable (Angularjs, javscript, jquery)

I'm having trouble checking/unchecking all cells in a column in my ng-handsontable. My controller looks like:

$scope.items= [{},{},{},{}];
$scope.columns = 
    {
      data: 'foo',
      title: "<input type='checkbox' onclick='console.log(items)' class='foo'>,
      type: 'checkbox',
      renderer: $scope.checkboxRenderer
    };

$scope.checkboxRenderer = function(instance, td, row, col, prop, value, cellProperties) {
    Handsontable.renderers.CheckboxRenderer.apply(this, arguments);
    if (value === true) {
      td.style.background = '#59e817';
    } else {
      td.style.background= '#ff2400';
    };
    return td;
  };

So far it works to color the boxes that are checked in the rows. The checkbox in the header can be checked or unchecked but I can't connect it to anything. When I try to log the items object to console or call a function defined in my controller, I get an error saying

$scope is not defined

or

items is not defined

How would I get access to the variables in my scope from within the checkbox in the header?




Aucun commentaire:

Enregistrer un commentaire