I have within ng-grid options:
afterSelectionChange: function (row, event) {
console.log("Event: " + event);
console.log("Row: " + row.rowIndex);
},
The first time a row is selected, it works as expected. The second time, it triggers twice, once for the row leaving, and again for the new row. This is fine. The issue is, I want to take action once, for the new row. The only way I can do that is by examining the event. However the event is undefined.
Output:
Event: undefined activityGridController.js:13
Row: 0 activityGridController.js:14
Event: undefined activityGridController.js:13
Row: 1
Question is, how to determine the new row?
You could just set an extra property with the beforeSelectionChange event. Something like this
beforeSelectionChange: function(row) {
row.changed = true;
return true;
},
afterSelectionChange: function (row, event) {
if (row.changed){
console.log("deal with row " + row.rowIndex);
row.changed=false;
}
},
check the row.selected the first row should be false and the send row should be true.
if(row && row.entity){
if(row.selected){
var selectedEntity = row.entity;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With