Reputation: 2089
I am using spark DataGrid. I want to emulate Excel Behaviour = When single cell is selected and users start to type on keyboard the selected cells goes to editing mode. I did it by starting gridItemEditorSession on 1st keyDown event but the problem I have is that after starting gridItemEditorSession value in the cell is selected so 2nd keyDown removes 1st keyDown character ;/
Here is demo: Simply select any cell and start typying:
<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
<![CDATA[
private function onKeyDown():void
{
trace(dataGrid.grid.anchorRowIndex)
trace(dataGrid.grid.caretRowIndex)
dataGrid.startItemEditorSession(dataGrid.grid.anchorRowIndex, dataGrid.grid.anchorColumnIndex)
}
private function onGridRollOver():void
{
}
]]>
</fx:Script>
<s:DataGrid id="dataGrid" requestedRowCount="5" width="350" editable="true"
height="300" selectionMode="multipleCells" keyDown="onKeyDown()"
gridRollOver="onGridRollOver()">
<s:ArrayCollection>
<s:DataItem key="1000" name="Abrasive" price="100.11" call="false"/>
<s:DataItem key="1001" name="Brush" price="110.01" call="true"/>
<s:DataItem key="1002" name="Clamp" price="120.02" call="false"/>
<s:DataItem key="1003" name="Drill" price="130.03" call="true"/>
<s:DataItem key="1004" name="Epoxy" price="140.04" call="false"/>
<s:DataItem key="1005" name="File" price="150.05" call="true"/>
<s:DataItem key="1006" name="Gouge" price="160.06" call="false"/>
<s:DataItem key="1007" name="Hook" price="170.07" call="true"/>
<s:DataItem key="1008" name="Ink" price="180.08" call="false"/>
<s:DataItem key="1009" name="Jack" price="190.09" call="true"/>
</s:ArrayCollection>
</s:DataGrid>
</s:Application>
Upvotes: 0
Views: 142
Reputation: 1091
I'm not too familair with Flex, but it sounds like you have a string handling issue. Something like
private function handleKeydown(e:KeyboardEvent):void
{
output_txt.text = String.fromCharCode(e.charCode);
}
instead of
private function handleKeydown(e:KeyboardEvent):void
{
output_txt.appendText(String.fromCharCode(e.charCode));
}
Make sure you're appending input to your text instead of replacing.
Upvotes: 1