2 Replies Latest reply on Dec 6, 2010 11:36 PM by qdechochen

    strange things using datagrid


      I write a itemrender for a datagridcolumn like this.



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

      <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" paddingLeft="4" paddingRight="4" width="100%" height="100%" dataChange="doDataChange()">



      public var configNode:XML;

      private function doDataChange():void



      var fieldValue:String=this.data["Growth"];





      private function DoSel(sVal:String):void


      var nodes:XMLList=configNode.children().(child("@Value")==sVal);



      var page:Object=this.parentDocument;

      var text:String=nodes[0].text();










      else if(sVal=="1")


      else if(sVal=="2")







      <mx:HBox id="Growth0" click="DoSel('0')" width="60" height="100%" borderColor="#BBBBBB" borderStyle="solid"/>

      <mx:HBox id="Growth1" click="DoSel('1')" width="60" height="100%" borderColor="#BBBBBB" borderStyle="solid"/>

      <mx:HBox id="Growth2" click="DoSel('2')" width="60" height="100%" borderColor="#BBBBBB" borderStyle="solid"/>

      <mx:Label id="GrowthText" width="80"/>




      This will show some graphics according to the value of "Growth", and I could change the value by clicking on the HBoxes(Growth0,Growth1,or Growth2).


      when i click the headtitle of Growth, the sorting works properly. But after I set values of Growth( by click on Growth0, or Growth1,or Growth2), and then click the Growth title, the sorting doesn't work. And what is more strange is that the rows become cluttered.


      This is the order before setting values and sorting.



      If i set some more values( by clicking ), and the sorting by thhe 5th column, which is "生长情况", it shows me:


      more repeated rows listed.


      Anyone knows how to solved that?

        • 1. Re: strange things using datagrid
          Flex harUI Adobe Employee

          Read the first item renderer post on my blog.  Renderers get recycled.

          You'll need to do things like unset growText.text if there is no configNode,




          Alex Harui

          Flex SDK Team

          Adobe System, Inc.


          • 2. Re: strange things using datagrid
            qdechochen Level 1

            Thank you for your reply.


            but i don't think it the reason because configNode is always not null in my code. And I modified the code to reset the itemrender as you said, but problem still appeared.


            And what's more strange is sorting by  other columns won't caused any problems. Only sorting by Growth cause these strange things.

            I know that renders may get recycled, while that would only cause "Growth" no refreshing when rows change. It won't show me more rows.

            Thanks again. And do you have any other suggestions?