It is not taking a long time to display, it will never display.

 

The problem is with the way you are updating the dataProvider.  Directly
setting a property on an item does not dispatch the necessary events to
cause the DG to update.  The two ways to do this are, 1, use the
collection API, which in this casw would be setItemAt() or 2, call
itemUpdated().  

 

Here is an example of the first:

    var oSelectedItem:Object = mc_searchrefund_grid.selectedItem;

    oSelectedItem.DATA2 = "NOT PRESENT";

    var iIndex:int = mc_searchrefund_grid.selectedIndex;

    testdata.setItemAt(oSelectedItem,iIndex);

 

Here is an example of the latter:

...

    mc_searchrefund_grid.selectedItem.DATA2 = "NOT PRESENT";

    testdata.itemUpdated(mc_searchrefund_grid.selectedItem,"DATA2");

 

Tracy

________________________________

From: [email protected] [mailto:[email protected]] On
Behalf Of Jason B
Sent: Monday, January 05, 2009 1:52 PM
To: [email protected]
Subject: [flexcoders] Re: Slow datagrid updates

 

Heres my example code on the issues im having
excuse the pasting mess :(

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
layout="absolute" backgroundColor="#FFFFFF">
<mx:Script>
<![CDATA[



public function setdata(){
//set data !
import mx.controls.Alert;
Alert.show(mc_searchrefund_grid.selectedItem.DATA2);
mc_searchrefund_grid.selectedItem.DATA2 = "NOT PRESENT";
}

]]>
</mx:Script>

<mx:ArrayCollection id="testdata">
<mx:Object>
<mx:DATA1>Test1</mx:DATA1>
<mx:DATA2>PRESENT</mx:DATA2>

</mx:Object>
<mx:Object>
<mx:DATA1>Test2</mx:DATA1>
<mx:DATA2>PRESENT</mx:DATA2>

</mx:Object>
</mx:ArrayCollection>

<mx:Canvas label="Search" width="100%" height="100%">

<mx:Label x="24" y="12" text="Testing Flex issue" width="119"/>

<mx:DataGrid x="0" y="57" width="892" id="mc_searchrefund_grid" 
dataProvider="{testdata}" height="240">
<mx:columns>
<mx:DataGridColumn headerText="User" dataField="DATA1"
width="10" />
<mx:DataGridColumn headerText="Comments" dataField="DATA2"
width="30" />
</mx:columns>
</mx:DataGrid>

<mx:Button x="50" y="305" label="test" click="setdata();"/>

</mx:Canvas>
</mx:Application>

 

Reply via email to