Is there a way to make text inside spark datagrid cells selectable? I don't want to make the cells editable.
I've tried extending the DefaultGridItemRenderer and setting selectable = true on it, but that does nothing.
I'm using Flex sdk 4.9
Is there a way to make text inside spark datagrid cells selectable? I don't want to make the cells editable.
I've tried extending the DefaultGridItemRenderer and setting selectable = true on it, but that does nothing.
I'm using Flex sdk 4.9
The DefaultGridItemRenderer uses FTETextField for displaying text, but text within a FTETextField can not be set as selectable.
Instead use UITextFieldGridItemRenderer; which does allow you to set selectable=true.
Easiest way is to create a subclass of UITextFieldGridItemRenderer and in its constructor add:
selectable = true;
Then set new class as renderer for datagrid.
If you don't want to create a custom class just to make your text selectable, using a ClassFactory will also work. In an actionscript function, use ClassFactory to create an instance of UITextFieldGridItemRenderer, set 'selectable' via the properties, and return the renderer instance. To apply the item renderer you would then bind that function to the 'itemRenderer' property of your column or grid.
Here is a simple example:
public function myRendererFactory():ClassFactory
{
var myRenderer:ClassFactory=new ClassFactory(UITextFieldGridItemRenderer);
myRenderer.properties={selectable: true};
return myRenderer;
}
...
<s:GridColumn itemRenderer="{myRendererFactory()}"/>
...