vthallam
vthallam

Reputation: 621

How to disable selection of some records based on a column value in Angular UI Grid?

I am using Angular UI Grid with enableRowHeaderSelection value as true. This allows user to select rows by clicking on the check box.

Is there a way to disable the row selection for certain rows based on a column value?

Upvotes: 2

Views: 9732

Answers (1)

Kyle
Kyle

Reputation: 5547

This is what you're looking for: http://ui-grid.info/docs/#/tutorial/210_selection

Working Plunker: http://plnkr.co/edit/vJbvJhgyKbYomW4VIsKs?p=preview

You can use an isRowSelectable function to determine which rows are selectable. If you set this function in the options after grid initialisation you need to call gridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS) to enable the option.

$scope.gridOptions.isRowSelectable = function(row) {
    if(row.entity.name === "Jack") return false;
    else return true;
}
$scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);

Upvotes: 8

Related Questions