1

I need to have 2 buttons in a cell. One is calling some function, other is disabling previous button that calls some function. I tried this(part of my template in a column):

return '<button kendo-button class="validate" ng-click="MyFunction($event)">' + txt.TXT_SEND_TO_SAP + '</button>' + '&nbsp;&nbsp;' +
'<button kendo-button ng-click="Disable($event)">disable</button>' + '&nbsp;&nbsp;'

and this function that calls disabling:

      $scope.Disable = function (e) {
      var data = $scope.grid.dataSource.view();
      for (var i = 0; i < data.length; i++) {
          $(data[i]).prev().prop("disabled", true)
      }
  }

what I do wrong? Thanks

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Aviator
  • 613
  • 4
  • 11
  • 26

1 Answers1

1

The event parameter (e) gives you the clicked button, e.target. From that you can get the button to disable via .prev(".validate") and then use the KendoUI widget to disable it:

$scope.Disable = function (e) {
  var btn = $(e.target);
  var toDisable = btn.prev(".validate").data("kendoButton");
  toDisable.enable(false);
}

DEMO

ezanker
  • 24,628
  • 1
  • 20
  • 35