In flex, is there a way to capture and optionally cancel a row selection event in a DataGrid?

混江龙づ霸主 提交于 2019-12-06 11:15:31

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;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!