Search code examples
listactionscript-3apache-flexflex-spark

spark list control showing incomplete data on dataProvider update


when i am updating a spark list like this:

searchView.gridView.dataProvider = new ArrayCollection( data );

i sometimes get the full data from the array "data" displayed in the list, but sometimes only the first four items. i checked and both the array and the dataProvider after setting it always have the correct number of entries.

here is the list code from the mxml:

<s:List id="gridView" width="1024" height="390" itemRenderer="com.xxx.xxx.view.component.GridViewItemRenderer">
    <s:layout>
        <s:TileLayout rowHeight="195" columnWidth="242" requestedColumnCount="4" horizontalGap="0" verticalGap="0" />
    </s:layout>
</s:List>

i can't figure out why it sometimes shows everything and then again shows just the first row.

UPDATE: it seems to be somehow connected to using the TileLayout. when i remove the layout it always displays all entries.

UPDATE 2: it also seems to only occur when i go from no items in the dataprovider (empty array) to n items. if there are already items displayed and the dataprovider gets updated with more or less items it works.


Solution

  • I had the same issue. I just used a band aid though. If you do this, it should show all.

    var myLayout:LayoutBase = gridView.layout;
    gridView.layout = null;
    gridView.layout = myLayout;
    

    Another option is just to create a new layout object and set it after the dataProvider.

    var newLayout = new TileLayout();
    newLayout.rowHeight = 195;
    newLayout.columnWidth = 242;
    newLayout.requestedColumnCount = 4;
    newLayout.horizontalGap = 0;
    newLayout.verticalGap = 0;
    
    gridView.dataProvider = newDataProvider;
    gridView.layout = newLayout;