Reputation: 57
Is there a way to exclude a column from being able to select row? in the example below I would like to make the age column unable to select the row.
http://plnkr.co/edit/OFoJydRpzoKAGBw3Tfzw?p=preview
$scope.gridOptions = { enableFullRowSelection: true, enableRowHeaderSelection: false };
$scope.gridOptions.columnDefs = [
{ name: 'id' },
{ name: 'name'},
{ name: 'age', displayName: 'Age (not focusable)', allowCellFocus : false },
{ name: 'address.city' }
];
$scope.gridOptions.multiSelect = false;
$scope.gridOptions.modifierKeysToMultiSelect = false;
$scope.gridOptions.noUnselect = true;
$scope.gridOptions.onRegisterApi = function( gridApi ) {
$scope.gridApi = gridApi;
gridApi.selection.on.rowSelectionChanged($scope,function(row){
var msg = 'row selected ' + row.isSelected;
$scope.callMe(row.entity);
});
};
Upvotes: 2
Views: 1248
Reputation: 21
As mentioned before, You need to use custom cell template and disable event propagation. Following Your code, cell template should be:
cellTemplate: '<div class=\"ui-grid-cell-contents\" ng-click="$event.stopPropagation()">{{row.entity.age}}</div>'
Please see this plunker http://plnkr.co/edit/BsmtzMQ9nNyWcSVuZDu4?p=preview
Upvotes: 2
Reputation: 9469
Try to use custom cellTemplate where you can handle cell click in a custom way (ignore click, or deselect row immediately).
Upvotes: 0