2

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?

1 Answer 1

8

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);
Sign up to request clarification or add additional context in comments.

3 Comments

I tried this and it's not working for me. I put this code in a method and calling after set the data to the grid. Is that the right way to do?
@vthallam See this working plunker: plnkr.co/edit/vJbvJhgyKbYomW4VIsKs?p=preview Put the method right into the $scope.gridOptions definition.
That worked perfectly! Can you please edit the answer and add that plunkr link. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.