2016-06-01 57 views
1

我已经创建了一个Angular Js UI网格,最后一列由一个按钮组成。 当点击那个按钮我需要获取该行的每个单元格的数据。 如果任何人都可以帮助我解决这个问题,将不胜感激。AngularJs - 如何获取单击行的单元格数据

var removeTemplate = '<input type="button" value="" style="background: url(../../Content/images/del-currency.png);widht:60px;height:30px" ng-click="removeRow()" />'; 
    $scope.selectedCurrencyGrid = { 
        data: 'selectedCurrencies', 
        multiSelect: false, 
        selectedItems: $scope.selectedCurrencyRow, 
        enableColumnResize: false, 
        enableRowSelection: true, 
        columnDefs: [ 
          { field: 'Name', displayName: 'Name' }, 
          { 
           field: 'IsDefault', 
           displayName: 'Default', 
           cellTemplate: '<input type="radio" name="radAnswer" ng-model="row.entity.IsDefault">' 
          }, 
          { name: 'Photo', field: 'photoP', displayName: '', cellTemplate: removeTemplate } 
        ] 

       }; 


$scope.removeRow = function() { 
      var index = this.row.rowIndex; 
      //need to get cell data of selected row 
     }; 

enter image description here

回答

1

添加row.entity到您的模板功能,
这会给你访问对象属性(行单元格):

<input type="button" value="" style="background: url(../../Content/images/del currency.png);widht:60px;height:30px" ng-click="removeRow(row.entity)" />';

确保您在功能conteroller得到一个参数:

$scope.removeRow = function (selectedRowObject) { 
      //Your logic... 
     }; 
+0

那正是我想要的,谢谢你soo多 –

+0

没问题,我推荐看看他们的文档,他们有很多很棒的功能。 http://ui-grid.info/docs/#/api – AranS

相关问题