5 Replies Latest reply on Apr 11, 2008 5:49 AM by Quatrol

    DG Header renderer problem

    Misenko
      Hi, I've encountered a problem with datagrid header renderer. I have custom header renderer based on let's say - Label, or something else, doesn't matter. Now when I run the application, everything is OK. Problem occuress, when I try to click on this header to sort data. Program runs into a loop and CPU is full loaded. I've tried to debug and I've found out, that my custom item renderer constructor (CustomHeaderRenderer ) is called all the time in a loop. Don't understand why... when I use standard header renderer, everything's ok.

      This is the whole code:

      package myClasses
      {

      import mx.controls.Label;

      public class CustomHeaderRenderer extends Label

      {


      public function CustomHeaderRenderer()
      {
      this.text = "Some Text";
      }
      }
      }

      Does anybody knows, where could be a problem ?? thanks
        • 1. Re: DG Header renderer problem
          Misenko Level 1
          nobody knows???
          • 2. Re: DG Header renderer problem
            Sreenivas R Adobe Employee
            Can you post the whole sample code? I tried the same thing and it seems to be working.
            • 3. Re: DG Header renderer problem
              Misenko Level 1
              Hi this is the whole code for header renderer class. Then I assign this header renderer to one of the columns in my datagrid... This is assignment:

              var myHeader:ClassFactory = new ClassFactory(CustomHeaderRenderer);
              myColumn.headerRenderer = myHeader;

              that's all. This loop of permanent creation of header renderer occures when I click on the header to sort...Only thing I can see is the sorting arrow, but the header text dissapear and application goes into a loop.
              • 4. Re: DG Header renderer problem
                Sreenivas R Adobe Employee
                Here is the sample code I tried. I tried it using Flex 2.0.1 and Flex 3. I am unable to reprodue your bug.

                quote:


                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">

                <mx:Script>
                <![CDATA[
                private var input:Array =
                [
                { x:100, y:10, z:11 },
                { x:20, y:12, z:14 },
                { x:10, y:14, z:18 },
                { x:10, y:14, z:18 }
                ];

                ]]>
                </mx:Script>

                <mx:DataGrid dataProvider="{input}">
                <mx:columns>
                <mx:DataGridColumn dataField="x" headerRenderer="CustomHeader" headerText="Sample" />
                <mx:DataGridColumn dataField="y" headerRenderer="CustomHeader" headerText="Sample" />
                <mx:DataGridColumn dataField="z" headerRenderer="CustomHeader" headerText="Sample" />
                </mx:columns>
                </mx:DataGrid>

                </mx:Application>



                quote:


                package
                {
                import mx.controls.Label;

                public class CustomHeader extends Label
                {
                public function CustomHeader()
                {
                super();
                this.text = "Some text";
                }

                }
                }

                • 5. Re: DG Header renderer problem
                  I've also stumbled upon this issue, the problem occurs when the data grid is using variable row heights.

                  here's an example with the problem occurring:

                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:Application
                  xmlns:mx=" http://www.adobe.com/2006/mxml"
                  xmlns:local="*"
                  layout="horizontal"
                  verticalAlign="middle"
                  initialize="initializeGridData()">

                  <mx:Script>
                  <![CDATA[
                  import mx.collections.ArrayCollection;

                  [Bindable]
                  private var gridData: ArrayCollection = new ArrayCollection();

                  public function initializeGridData():void
                  {
                  for (var i: uint = 0; i < 5; i++)
                  {
                  var item: Object = new Object();
                  item.sequence = i;
                  gridData.addItem(item);
                  }
                  }
                  ]]>
                  </mx:Script>

                  <mx:DataGrid id="rankedGrid" dataProvider="{gridData}"
                  allowMultipleSelection="true" variableRowHeight="true">
                  <mx:columns>
                  <mx:DataGridColumn headerText="fixed wdith really long label"
                  width="50" dataField="sequence" headerRenderer="mx.controls.Label"/>
                  </mx:columns>
                  </mx:DataGrid>
                  </mx:Application>