2

I am curious if there is a way to get Angular Grid to listen of a "deselect" devent, similar to it's "rowSelected" event.

I have a table where one column is a checkbox. I would like that table to send a POST indicating whether a checkbox has been selected or deselected (the server will want to know which one it was).

I was able to get the table to send a message when the checkbox is selected using:

$scope.gridOptions = {
                      rowSelected: myRowSelectFunc,
                      rowDeselected: myRowDeselectedFunc // Is there a listener for this?
}

function myRowSelectFunc(row) {
    $http({method: 'POST',
           url: 'api/submit',
           params: { selected: true,
                     userid: row.userid}});

}

function myRowDeselectFunc(row) {
    $http({method: 'POST',
           url: 'api/submit',
           params: { selected: true,
                     userid: row.userid}});

}

However, I am not sure how to do the same on a row deselect.

Thanks!

slee
  • 287
  • 2
  • 7
  • 15

1 Answers1

1

There is no event listener for deselecting a row. Though you can perform your logic in the selected event using a flag

$scope.gridOptions = {
                  rowSelected: myRowSelectFunc($event)
}
function myRowDeselectFunc(event) {
if(event.node.isSelected()) {
   // your deselection logic
}
else {   
$http({method: 'POST',
       url: 'api/submit',
       params: { selected: true,
                 userid: row.userid}});
  }
}

Hope it helps !

Ponnapally
  • 88
  • 1
  • 13