I am enabling multiple row selection with clicking checkbox Item renderer.
this works for extending mx:Datagrid (other answer)
override protected function selectItem(item:IListItemRenderer,
shiftKey:Boolean, ctrlKey:Boolean,
transition:Boolean = true):Boolean
{
// only run selection code if a checkbox was hit and always
// pretend we're using ctrl selection
if (item is CheckBox)
return super.selectItem(item, shiftKey, true, transition);
else //Avenir Cokaj 23/06/11: this enables the flex's natural selection
return super.selectItem(item, shiftKey, ctrlKey, transition);
}
But there is no super.selectItem in s:Datagrid So how to enable control key on spark datagrid?
Use the selectionMode property. No more subclassing required. In your case, you would want to set it to
multipleRows.Other values are:
I believe they are pretty self-explanatory.
Now if you wish the rows to be multi-selected with a single click (as if the control key were constantly pressed), you can do this by subclassing DataGrid like this:
We just intercept the event and set its
ctrlKeyproperty to always betrue.