1

我创建了一个 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
        };

在此处输入图像描述

4

1 回答 1

1

添加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...
        };
于 2016-06-01T07:15:37.730 回答