ngGrid - remove row

前端 未结 6 703
猫巷女王i
猫巷女王i 2021-02-04 15:34

I have been looking for an example on how to implement a button to remove a selected row, but I couldn\'t find anything useful so far.

Can anyone please give me a hint?

6条回答
  •  [愿得一人]
    2021-02-04 16:05

    This works:

    showSelectionCheckbox : true ->it adds checkbox to grid and $scope.delItem = function() -> it works for both multiple rows or single row selection

         $scope.mySelections = [];
                     $scope.gridOptions = {
                         data :'data',
                         selectedItems : $scope.mySelections,
                         showSelectionCheckbox : true
                     } 
    
     $scope.delItem = function() {
          for (var i = 0; i < $scope.mySelections.length; i++) {
                 var index = $scope.data.indexOf($scope.mySelections[i]);
                 if (index != -1) {
                     $scope.data.splice(index, 1);
                 }
             }
         }
    

提交回复
热议问题