简体   繁体   中英

how to disable button in kendo grid column

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM