1 Reply Latest reply on Feb 1, 2012 1:18 PM by Carol L. Frampton

    Spark DataGrid Performance Issue

    yoyonbo

      Hi, Now I use the customized GridItemRenderer with spark DataGrid.

       

      My DataGrid has 31column and 20 rows and display text or icon image.

       

      At first, I displayed only text data when grid has 100 rows in dataProvider.

       

      But vertical scroll performance was very slow.

       

      I think setting text data in the label causes this result.

       

      Does anyone know improve scroll performance?

       

      I use this GridItemRenderer.

       

       

      ----------------------------------------------------------------

      <?xml version="1.0" encoding="utf-8"?>

      <s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"

                                                        xmlns:s="library://ns.adobe.com/flex/spark"

                                                        xmlns:mx="library://ns.adobe.com/flex/mx" clipAndEnableScrolling="true">

       

                <fx:Script>

                          <![CDATA[

                                    import mx.core.IVisualElement;

                                    import mx.events.PropertyChangeEvent;

       

                                    import spark.components.gridClasses.IGridVisualElement;

       

                                    private static const yellow:uint = 0xffff66;

                                    private static const pink:uint = 0xffcccc;

                                    private static const white:uint = 0xffffff;

       

                                      override public function prepare(hasBeenRecycled:Boolean):void {

                                               //if data is updated, draw cell pink

                                               if(data[column.dataField + "_flg"] == "true") {

                                                        backColor.color = pink;

                                                        backColor.alpha = 1;

                                              } else {

                                                        backColor.color = white;

                                                        backColor.alpha = 0;

                                              }

                                    }  

       

                          ]]>

                </fx:Script>

       

                <s:Rect id="rectRange" top="0" bottom="0" right="0" left="0">

                          <s:fill>

                                    <s:SolidColor id="backColor" alpha="0"/>

                          </s:fill>

                </s:Rect>

       

                <s:Label id="labelDisplay"

                                     left="3" right="3" top="3" bottom="3"

                                     textAlign="center"

                                     verticalAlign="middle"

                                     />

       

      </s:GridItemRenderer>

       

      ----------------------------------------------------------------