This should be trivial, but I can't seem to figure out a way to do this.
I have a DataGrid, and what I would like to do, is when a user clicks on a row to select it, check a certain condition, and if it's met prevent the row from getting selected and keep the old selection intact.
Thanks!
I didn't test it, but it should work using event.preventDefault() and/or event.stopImmediatePropagation() on the GridSelectionEvent.SELECTION_CHANGING event.
//stupid function but used for example purpose
private function addListener():void
{
dataGrid.addEventListener(GridSelectionEvent.SELECTION_CHANGING, onSelectionChanging)
}
private function onSelectionChanging(event:GridSelectionEvent):void
{
if(!canRowBeSelected(event.selectionChange.rowIndex))
{
event.stopImmediatePropagation();
event.preventDefault();
}
}
private function canRowBeSelected(index:int):Boolean
{
//add logic
return false;
}