0 Replies Latest reply on Sep 1, 2008 6:35 AM by zrflex

    OLAP Data Grid Header Rendering

    zrflex
      I have a problem with custom made header renderer for olap data grid.

      Here is the piece of code:
      ****************************************************************************************** ***************
      <mx:Style>.quarterStyle{ color: #aabbcc;}</mx:Style>
      <mx:Style>.customerStyle{ color: #ffffaa;}</mx:Style>
      <mx:OLAPDataGrid id="myOLAPDG" width="100%" height="100%" minColumnWidth="200" horizontalScrollPolicy="auto" verticalScrollPolicy="auto" >
      <mx:headerRendererProviders>
      <mx:OLAPDataGridHeaderRendererProvider uniqueName="CustomerDim" type="{OLAPDataGrid.OLAP_DIMENSION}" styleName="customerStyle" />
      <!-- <mx:OLAPDataGridHeaderRendererProvider uniqueName="QuarterDim" type="{OLAPDataGrid.OLAP_DIMENSION}" styleName="quarterStyle" /> -->
      <mx:OLAPDataGridHeaderRendererProvider uniqueName="QuarterDim" type="{OLAPDataGrid.OLAP_DIMENSION}" renderer="com.zr.headerrenderers.ZrTestHeaderRenderer" />
      </mx:headerRendererProviders>

      ****************************************************************************************** ************************
      When the code executes with first and second OLAPDataGridHeaderRendererProvider lines active and the third one commented out, it works just fine. Styling of header works. When I try to go further from styling and introduce custom header renderer claSS SYSTEM FAILS. When I comment out second line and decomment third OLAPDataGridHeaderRendererProvider line execution blows and the following exception is thrown:

      ****************************************************************************************** **************************
      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at mx.controls.olapDataGridClasses::OLAPDataGridHeaderRenderer/measure()[C:\Work\flex\dmv_au tomation\projects\datavisualisation\src\mx\controls\olapDataGridClasses\OLAPDataGridHeader Renderer.as:308]
      at mx.core::UIComponent/measureSizes()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\cor e\UIComponent.as:5819]
      at mx.core::UIComponent/validateSize()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\cor e\UIComponent.as:5765]
      at mx.core::Container/validateSize()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\ Container.as:2657]
      at mx.managers::LayoutManager/validateClient()[E:\dev\3.0.x\frameworks\projects\framework\sr c\mx\managers\LayoutManager.as:817]
      at mx.controls::AdvancedDataGrid/createHeaderItems()[C:\Work\flex\dmv_automation\projects\da tavisualisation\src\mx\controls\AdvancedDataGrid.as:1541]
      at mx.controls::AdvancedDataGrid/createHeaderItems()[C:\Work\flex\dmv_automation\projects\da tavisualisation\src\mx\controls\AdvancedDataGrid.as:1504]
      at mx.controls::AdvancedDataGrid/createHeaders()[C:\Work\flex\dmv_automation\projects\datavi sualisation\src\mx\controls\AdvancedDataGrid.as:1401]
      at mx.controls::OLAPDataGrid/createHeaders()[C:\Work\flex\dmv_automation\projects\datavisual isation\src\mx\controls\OLAPDataGrid.as:1542]
      at mx.controls::AdvancedDataGrid/calculateHeaderHeight()[C:\Work\flex\dmv_automation\project s\datavisualisation\src\mx\controls\AdvancedDataGrid.as:3062]
      at mx.controls::AdvancedDataGridBaseEx/makeRowsAndColumns()[C:\Work\flex\dmv_automation\proj ects\datavisualisation\src\mx\controls\AdvancedDataGridBaseEx.as:1895]
      at mx.controls::AdvancedDataGrid/makeRowsAndColumns()[C:\Work\flex\dmv_automation\projects\d atavisualisation\src\mx\controls\AdvancedDataGrid.as:7089]
      at mx.controls.listClasses::AdvancedListBase/makeRowsAndColumnsWithExtraRows()[C:\Work\flex\ dmv_automation\projects\datavisualisation\src\mx\controls\listClasses\AdvancedListBase.as: 1230]
      at mx.controls.listClasses::AdvancedListBase/updateDisplayList()[C:\Work\flex\dmv_automation \projects\datavisualisation\src\mx\controls\listClasses\AdvancedListBase.as:3500]
      at mx.controls::AdvancedDataGridBaseEx/updateDisplayList()[C:\Work\flex\dmv_automation\proje cts\datavisualisation\src\mx\controls\AdvancedDataGridBaseEx.as:1758]
      at mx.controls::AdvancedDataGrid/updateDisplayList()[C:\Work\flex\dmv_automation\projects\da tavisualisation\src\mx\controls\AdvancedDataGrid.as:5924]
      at mx.controls::OLAPDataGrid/updateDisplayList()[C:\Work\flex\dmv_automation\projects\datavi sualisation\src\mx\controls\OLAPDataGrid.as:1590]
      at mx.controls.listClasses::AdvancedListBase/validateDisplayList()[C:\Work\flex\dmv_automati on\projects\datavisualisation\src\mx\controls\listClasses\AdvancedListBase.as:3071]
      at mx.managers::LayoutManager/validateDisplayList()[E:\dev\3.0.x\frameworks\projects\framewo rk\src\mx\managers\LayoutManager.as:602]
      at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:675]
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\sr c\mx\core\UIComponent.as:8460]
      at mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src \mx\core\UIComponent.as:8403]

      ****************************************************************************************** **************
      When I debugged I found that variable factories in the class OLAPDataGridHeaderRenderer is null and that is why it fails.

      Custom header renderer that I made for this case is very simple extension. For this exercise I just wanted
      to proof that my custom renderer will be the one that will show up on a data grid. I want to do more. I want to
      make an extension of canvas there and place some components it, but I can not proceed because it fails on this simple proof of concept.

      The code for custom renderer is here:
      ****************************************************************************************** **************
      package com.zr.headerrenderers
      {
      import mx.controls.olapDataGridClasses.OLAPDataGridHeaderRenderer;
      import mx.core.*;

      public class ZrTestHeaderRenderer extends OLAPDataGridHeaderRenderer
      {
      public function ZrTestHeaderRenderer()
      {
      super();
      super.styleName="quarterStyle";
      }
      }
      }

      ****************************************************************************************** *********************
      here is what flex documentation says about the issue and I think that I defined all key elements.
      The OLAPDataGridHeaderRendererProvider class lets you specify a custom header renderer for the columns in the OLAPDataGrid control.
      To specify a custom header renderer to the OLAPDataGrid control, create your customer header renderer as a subclass of the OLAPDataGridHeaderRenderer class, create an instance of the OLAPDataGridHeaderRendererProvider, set the OLAPDataGridHeaderRendererProvider.renderer property to your customer header renderer, and then pass the OLAPDataGridHeaderRendererProvider instance to the OLAPDATAGrid control by setting the OLAPDataGrid.headerRendererProviders property.

      Have anybody had the similar issue and is willing to help me sort this out?

      Thanx.