Angularjs Angular JS-UI网格启用FullRowSelection rowSelectionChanged事件

Angularjs Angular JS-UI网格启用FullRowSelection rowSelectionChanged事件,angularjs,angular-ui-grid,Angularjs,Angular Ui Grid,我正在为网格使用ui网格。我想创建一个网格,其中包含数据库中的一些列和按钮的额外列 $scope.studentgrid = { data: 'students', enableFiltering: false, onRegisterApi: function(gridApi){ $scope.gridApi = gridApi; $scope.gridApi.grid.registerRowsProcessor( $scope.s

我正在为网格使用ui网格。我想创建一个网格,其中包含数据库中的一些列和按钮的额外列

    $scope.studentgrid = {
    data: 'students',
    enableFiltering: false,
    onRegisterApi: function(gridApi){
        $scope.gridApi = gridApi;
        $scope.gridApi.grid.registerRowsProcessor( $scope.singleFilter, 200 );
    },

    enableRowSelection: true,
    multiSelect: false,
    enableColumnResizing: true,
    enableSelectAll:true,
    enableCellEdit: false,
    enableFullRowSelection: true,
    enableCellEditOnFocus: false,        
    columnDefs: [
        { field: 'ID'},
        { field: 'name'},
        { field: 'age' },
        { field: 'email', displayName: 'Email(Sorting Disabled)', enableSorting: false },
        { field: 'Change', cellTemplate: '<div><button ng-click="grid.appScope.genalert()">Click Here</button></div>'}
    ]
};

每次单击按钮时,rowSelectionChanged事件都会触发。单击按钮时,如何停止要触发的rowSelectionChanged事件?我需要使enableFullRowSelection为true。

我没有找到一种方法来吞下
rowSelectionChanged
事件。不过,我确实找到了解决这个问题的方法,在您的具体案例中,这可能有用,也可能无用。在我的例子中,我在rowSelectionChange上有一个特定的操作,我想在单击按钮时阻止它发生。如果这对你有效,我会这样做

更改您的cellTemplate以包含按钮单击的布尔值:

cellTemplate: '<div><button ng-click="grid.appScope.buttonClicked = true;grid.appScope.genalert()">Click Here</button></div>'
cellTemplate: '<div><button ng-click="grid.appScope.buttonClicked = true;grid.appScope.genalert()">Click Here</button></div>'
gridApi.selection.on.rowSelectionChanged($scope, function (row) {
    if (!this.grid.appScope.buttonClicked) {
        alert(row.isSelected);
    }
    this.grid.appScope.buttonClicked = false;
});