Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems adding new rows to mx DataGrid
    primarykey
    data
    text
    <p>I'm using mx:DataGrid and I cannot change to spark (it's a legacy project). The DataGrid is editable and when the users get in the last column I want to add a new column and start the edit mode in the first column of the new row. I can do this. </p> <p>My problem is that sometimes the last column cannot be edited, so I added an itemEditBeginning listener to stop the edit and add the new row. That's my problem. When the user get in the last field, the new row is added but I cannot see it. I have to click in the column header to sort datagrid data, then the new rows appears. It's kind of a delay.</p> <p>My code is bigger, but this simple code can reproduce the same problem:</p> <pre><code>&lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="application1_creationCompleteHandler(event)" minWidth="955" minHeight="600"&gt; &lt;fx:Script&gt; &lt;![CDATA[ import mx.collections.ArrayCollection; import mx.events.CollectionEvent; import mx.events.CollectionEventKind; import mx.events.DataGridEvent; import mx.events.FlexEvent; [Bindable] public var itens:ArrayCollection; protected function application1_creationCompleteHandler(event:FlexEvent):void { itens = new ArrayCollection(); itens.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChange); itens.addItem({a: '1', b: '2'}); } protected function onCollectionChange(event:CollectionEvent):void { if (event.kind == CollectionEventKind.ADD) { var row:int = itens.length - 1; var column:int = 0; var args:Array = [row, column]; callLater(moveTo, args); } } protected function moveTo(row:int, col:int):void { itensDg.editedItemPosition = { rowIndex:row, columnIndex:col }; } protected function addInfo():void { itens.addItem({a: '10', b: '20'}); } protected function itensDg_itemEditBeginningHandler(event:DataGridEvent):void { if (event.columnIndex == 1) { event.preventDefault(); addInfo(); } } ]]&gt; &lt;/fx:Script&gt; &lt;mx:DataGrid id="itensDg" dataProvider="{itens}" editable="true" itemEditBeginning="itensDg_itemEditBeginningHandler(event)" /&gt; &lt;/s:Application&gt; </code></pre> <p>Any tips about how to solve this?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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