AngularJs - 如何获取点击行的单元格数据

AngularJs - How to get cell data of clicked row

我创建了一个 Angular Js ui-grid,最后一列包含一个按钮。 单击该按钮时,我需要获取该行每个单元格的数据。 如果有人能帮我解决这个问题,我将不胜感激。

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
        };

row.entity 添加到您的模板函数,
这将使您能够访问对象属性(行单元格):

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

确保控制器中的函数获取参数:

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