Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to add a datagrid row on key down event?
    text
    copied!<p>I have a datagrid with one row intially. When I click on the first row, i.e on key down event, I want another row to be added. </p> <p>Earlier I had a button, on clicking which I added the row. But now I want the row to be added automatically once I click the first row. How to do that? </p> <p>I added keydown event to the datagrid, but it threw some error.</p> <p>Can someone help me? I have given my code here. I have a text box and a button in the task component. When I click the text box in the task component, I want the addTaskRow function to be called..</p> <pre><code> &lt;mx:Script&gt; &lt;![CDATA[ import mx.collections.ArrayCollection; import mx.rpc.events.ResultEvent; import mx.collections.XMLListCollection; [Bindable] private var initDG:ArrayCollection = new ArrayCollection([ {Select:true}, ]); private function addTaskRow(event:MouseEvent):void { taskDataGrid.dataProvider.addItem( { } ); taskDataGrid.height += 30; } ]]&gt; &lt;/mx:Script&gt; &lt;mx:DataGrid id="taskDataGrid" dataProvider="{initDG}" variableRowHeight="true" editable="true" width="100%" paddingBottom="1" paddingTop="1" height="47"&gt; &lt;!--mx:DataGrid id="taskDataGrid" dataProvider="{initDG}" rowCount="1" variableRowHeight="true" editable="true" width="100%" keyDown="addTaskRow(event);"--&gt; &lt;mx:columns&gt; &lt;mx:DataGridColumn dataField="Select" editable="true" rendererIsEditor="true" itemRenderer="mx.controls.CheckBox" editorDataField="selected" /&gt; &lt;mx:DataGridColumn dataField="TaskName" width="220" editable="true" rendererIsEditor="true" itemRenderer="components.taskComponent"/&gt; &lt;mx:DataGridColumn dataField="TaskId" itemRenderer="mx.controls.TextInput" /&gt; &lt;mx:DataGridColumn dataField="TaskType" itemRenderer="mx.controls.TextInput"/&gt; &lt;mx:DataGridColumn dataField="ProjectWon" itemRenderer="mx.controls.TextInput"/&gt; &lt;mx:DataGridColumn dataField="ItemCodeVersion" itemRenderer="mx.controls.TextInput"/&gt; &lt;/mx:columns&gt; &lt;/mx:DataGrid&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload