Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex: spark DataGrid displays value other than the current value in dataProvider
    primarykey
    data
    text
    <p>I have 2 flex datagrids on a screen. The user can select one or more rows from either datagrid and move them to the other datagrid. The lower table is empty when entering the application. For example: </p> <pre><code>Item Color Price -------------------- item57 red $5.55 item62 blue $5.29 item808 green $2.21 Row Item Color Price --------------------------- </code></pre> <p>Note there is a column that numbers the rows on the bottom datagrid (only).</p> <p>When I enter the application and move, for example, 3 rows from the top to bottom grid, the row numbers are fine (they show rows 1, 2, and 3). For example:</p> <pre><code>Item Color Price -------------------- Row Item Color Price --------------------------- 1 item57 red $5.55 2 item62 blue $5.29 3 item808 green $2.21 </code></pre> <p>If I then move, for example, row 1 in the bottom grid back to the top...</p> <pre><code>Item Color Price -------------------- item57 red $5.55 Row Item Color Price --------------------------- 1 item62 blue $5.29 2 item808 green $2.21 </code></pre> <p>and then back again to the bottom grid...</p> <pre><code>Item Color Price -------------------- Row Item Color Price --------------------------- 1 item62 blue $5.29 2 item808 green $2.21 1 item57 red $5.55 </code></pre> <p>the row number is supposed to display 3 because it inserts into the bottom grid at the end of the list, but when it does this, it displays the (old) row number value of 1.</p> <p>When I debug and look at the dataprovider = _myData, I see the <code>rowNumber</code> value for the row in question (for item57 above) equals 3 (as it should). However, it is displayed in the lower datagrid as 1.</p> <p><strong>How can the dataprovider value be different than what is displayed in the DataGrid?</strong> </p> <p>[I can also debug and look at <code>gridLower</code> column information, and it also shows the correct value of 3 for <code>rowNumber</code> for the data in question.]</p> <p>The lower datagrid is similar to the following (although I'm using a custom itemRenderer, removed for simplicity here):</p> <pre><code>[Bindable] private var _myData:ListCollectionView=new ListCollectionView(new ArrayList()); ... &lt;s:DataGrid dataProvider="{_myData}"&gt; &lt;s:columns&gt; &lt;fx:Array&gt; &lt;s:GridColumn id="gridLower" headerText="myHeader" dataField="rowNumber"/&gt; ... </code></pre> <p>The function that adds the upper table's row(s) to the lower table is:</p> <pre><code>private function addRow():void { var selectedIndices:Object=gridUpper.grid.selectedIndices; for (var i:int=selectedIndices.length-1;i&gt;=0;i--) { var item:Object=_upperTableData.removeItemAt(selectedIndices[i]); item.rowNumber=_myData.length+1; _myData.list.addItem(item); } // I tried adding "_myData.refresh();" here and it had no effect // I tried adding "ListCollectionView(gridLower.dataProvider).refresh();" and it had no effect // I tried adding "grid2.dataProvider.refresh();" here but it had no effect } </code></pre> <p>UPDATE 1: If I re-sort any column in the lower table, the correct values appear. I seem to be observing what's reported in this link: <a href="http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/" rel="nofollow">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/</a> Haven't found a solution yet though. See attempts in my <code>addRow()</code> function above. Am I on the right track?</p> <p>UPDATE 2: While re-sorting manually corrects the data in the lower grid, I haven't found a way to do this programmatically. I tried inserting:</p> <pre><code>_myData.sort=null; var complete:Boolean=_myData.refresh(); </code></pre> <p>just before the end of <code>addRow()</code> function above, but it didn't resolve my issue. When debugging, <code>complete</code> is true, but still the lower grid displays the stale data.</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.
 

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